What Is a .DEB File?
Debian binary package
Debian Package (DEB) Format
Overview
Debian Package (DEB) is a package format used by Debian-based Linux distributions (Ubuntu, Mint, Kali, etc.) for software distribution and installation. DEB packages contain compiled software, configuration files, dependencies information, and installation scripts, providing a standardized way to distribute and manage software on Debian-based systems.
Technical Details
File Extension: .deb
MIME Type: application/vnd.debian.binary-package
Archive Format: AR archive containing tar archives
Compression: gzip, xz, bzip2, lzma
Package Manager: dpkg, apt, aptitude
Architecture Support: Multiple (amd64, i386, arm64, armhf, etc.)
DEB packages contain:
- Binary files and executables
- Configuration files and documentation
- Control information and metadata
- Pre/post installation scripts
Key Features
- Dependency Management: Automatic dependency resolution
- Digital Signatures: GPG signature verification
- Configuration Handling: Proper config file management
- Installation Scripts: Pre/post install customization
- Multi-Architecture: Support for different CPU architectures
- Atomic Operations: Safe install/remove operations
Package Structure
DEB Package Structure:
├── debian-binary (format version)
├── control.tar.{gz,xz} (control information)
│ ├── control (package metadata)
│ ├── preinst (pre-installation script)
│ ├── postinst (post-installation script)
│ ├── prerm (pre-removal script)
│ ├── postrm (post-removal script)
│ ├── conffiles (configuration files list)
│ ├── md5sums (file checksums)
│ └── triggers (system triggers)
└── data.tar.{gz,xz} (actual files)
├── usr/
├── etc/
├── var/
└── other filesystem paths
Control File Format
Main Control File
Package: mypackage
Version: 1.0.0-1
Architecture: amd64
Maintainer: John Doe <john@example.com>
Installed-Size: 1024
Depends: libc6 (>= 2.34), libssl3 (>= 3.0.0)
Recommends: curl, wget
Suggests: vim
Conflicts: oldpackage
Replaces: oldpackage
Provides: virtual-package
Section: utils
Priority: optional
Homepage: https://example.com/mypackage
Description: A sample package for demonstration
This package provides useful utilities for system administration.
It includes several command-line tools and configuration files.
.
This is the extended description that can span multiple lines.
Version Format
Version: [epoch:]upstream_version[-debian_revision]
Examples:
1.0.0-1 # Standard version
2:1.5.2-3ubuntu1 # With epoch and Ubuntu revision
1.0~beta1-1 # Pre-release version
1.0+dfsg-2 # Modified upstream version
Dependencies
# Exact version
Depends: package (= 1.0.0-1)
# Version ranges
Depends: package (>= 1.0.0), package (<< 2.0.0)
# Multiple packages
Depends: libc6, libssl3, python3 (>= 3.9)
# Alternative dependencies
Depends: mail-transport-agent | postfix
# Virtual packages
Provides: httpd
Depends: httpd
Common Use Cases
- Software Distribution: Installing applications and tools
- System Updates: Updating OS components and libraries
- Development Libraries: Installing development headers and tools
- Configuration Packages: System configuration and themes
- Enterprise Deployment: Custom internal software distribution
- Embedded Systems: Firmware and system component updates
Package Management Commands
dpkg (Low-level)
# Install package
sudo dpkg -i package.deb
# Remove package
sudo dpkg -r packagename
# Purge package (including config files)
sudo dpkg -P packagename
# List installed packages
dpkg -l
dpkg -l | grep packagename
# Show package information
dpkg -s packagename
# List package contents
dpkg -L packagename
# Show files in package file
dpkg -c package.deb
# Extract package without installing
dpkg -x package.deb /tmp/extracted
# Extract control information
dpkg -e package.deb /tmp/control
# Verify package integrity
dpkg -V packagename
# Fix broken dependencies
sudo dpkg --configure -a
apt (High-level)
# Update package lists
sudo apt update
# Install package
sudo apt install packagename
# Install local deb file
sudo apt install ./package.deb
# Remove package
sudo apt remove packagename
sudo apt purge packagename # Remove including config files
# Upgrade packages
sudo apt upgrade
sudo apt full-upgrade
# Search packages
apt search keyword
apt list --installed | grep packagename
# Show package information
apt show packagename
# Download package without installing
apt download packagename
# Clean package cache
sudo apt clean
sudo apt autoclean
sudo apt autoremove
Building DEB Packages
Manual Package Creation
# Create package directory structure
mkdir -p mypackage/DEBIAN
mkdir -p mypackage/usr/bin
mkdir -p mypackage/usr/share/doc/mypackage
# Create control file
cat > mypackage/DEBIAN/control << EOF
Package: mypackage
Version: 1.0.0-1
Architecture: amd64
Maintainer: John Doe <john@example.com>
Description: My custom package
Extended description here
Depends: bash
EOF
# Add files
cp mybinary mypackage/usr/bin/
cp README.md mypackage/usr/share/doc/mypackage/
# Set permissions
chmod 755 mypackage/usr/bin/mybinary
chmod 644 mypackage/usr/share/doc/mypackage/README.md
# Build package
dpkg-deb --build mypackage
Using debhelper
# Install build tools
sudo apt install build-essential devscripts debhelper
# Create source package
dh_make --createorig -s -p mypackage_1.0.0
# Edit debian/control
cat > debian/control << EOF
Source: mypackage
Section: utils
Priority: optional
Maintainer: John Doe <john@example.com>
Build-Depends: debhelper (>= 10)
Standards-Version: 4.1.2
Package: mypackage
Architecture: any
Depends: \${shlibs:Depends}, \${misc:Depends}
Description: My package description
Extended description
EOF
# Build package
debuild -us -uc
Advanced debian/rules
#!/usr/bin/make -f
%:
dh $@
override_dh_auto_configure:
./configure --prefix=/usr --sysconfdir=/etc
override_dh_auto_install:
$(MAKE) DESTDIR=debian/mypackage install
# Custom installation steps
mkdir -p debian/mypackage/etc/mypackage
cp config/* debian/mypackage/etc/mypackage/
override_dh_installsystemd:
dh_installsystemd --name=mypackage
override_dh_auto_test:
# Skip tests if needed
true
Installation Scripts
Pre-installation Script (preinst)
#!/bin/sh
set -e
case "$1" in
install)
# Create user if needed
if ! getent passwd myuser > /dev/null; then
useradd --system --home /var/lib/mypackage myuser
fi
;;
upgrade)
# Handle upgrade preparations
systemctl stop myservice || true
;;
esac
exit 0
Post-installation Script (postinst)
#!/bin/sh
set -e
case "$1" in
configure)
# Set up permissions
chown myuser:myuser /var/lib/mypackage
chmod 750 /var/lib/mypackage
# Enable and start service
systemctl enable myservice
systemctl start myservice
# Update configuration
if [ -x /usr/sbin/update-alternatives ]; then
update-alternatives --install /usr/bin/mycommand mycommand /usr/bin/mypackage-cmd 50
fi
;;
esac
exit 0
Pre-removal Script (prerm)
#!/bin/sh
set -e
case "$1" in
remove|deconfigure)
# Stop service
systemctl stop myservice || true
systemctl disable myservice || true
;;
upgrade)
# Prepare for upgrade
;;
esac
exit 0
Post-removal Script (postrm)
#!/bin/sh
set -e
case "$1" in
remove)
# Clean up runtime files
rm -rf /var/run/mypackage
;;
purge)
# Remove all traces including config
rm -rf /etc/mypackage
rm -rf /var/lib/mypackage
# Remove user
if getent passwd myuser > /dev/null; then
userdel myuser
fi
;;
esac
exit 0
Package Quality and Standards
Lintian Checks
# Install lintian
sudo apt install lintian
# Check package
lintian package.deb
# Check source package
lintian -i -I --show-overrides package.dsc
# Common issues and fixes:
# - Binary without man page
# - Missing copyright file
# - Wrong permissions
# - Spelling errors in description
Policy Compliance
# Debian Policy Manual compliance
# - Use standard directories (/usr, /etc, /var)
# - Follow FHS (Filesystem Hierarchy Standard)
# - Proper dependency declarations
# - Maintainer scripts best practices
# - Configuration file handling
Repository Management
Creating APT Repository
# Create repository structure
mkdir -p myrepo/{pool,dists/stable/main/binary-amd64}
# Copy packages
cp *.deb myrepo/pool/
# Generate Packages file
cd myrepo
dpkg-scanpackages pool /dev/null | gzip -9c > dists/stable/main/binary-amd64/Packages.gz
# Generate Release file
cat > dists/stable/Release << EOF
Suite: stable
Codename: stable
Components: main
Architectures: amd64
Date: $(date -Ru)
EOF
# Sign repository
gpg --armor --detach-sign --output dists/stable/Release.gpg dists/stable/Release
Using Repository
# Add repository
echo "deb [trusted=yes] https://myrepo.example.com/myrepo stable main" | sudo tee /etc/apt/sources.list.d/myrepo.list
# Add GPG key
wget -qO - https://myrepo.example.com/key.gpg | sudo apt-key add -
# Update and install
sudo apt update
sudo apt install mypackage
Advanced Features
Multi-Architecture Support
# Enable multi-arch
sudo dpkg --add-architecture i386
# Build for different architectures
dpkg-buildpackage -a armhf
dpkg-buildpackage -a arm64
# Cross-compilation
export CC=arm-linux-gnueabihf-gcc
dpkg-buildpackage -a armhf
Package Triggers
# debian/triggers
interest /usr/share/applications
interest-noawait /usr/lib/mime/packages
# Handle triggers in postinst
case "$1" in
triggered)
update-desktop-database
update-mime-database /usr/share/mime
;;
esac
Configuration Management
# debian/conffiles
/etc/mypackage/config.conf
/etc/mypackage/settings.ini
# Handle config files in maintainer scripts
if [ "$1" = "configure" ]; then
ucf /usr/share/mypackage/config.conf /etc/mypackage/config.conf
fi
Troubleshooting
Common Issues
# Broken dependencies
sudo apt --fix-broken install
# Package conflicts
sudo dpkg --force-overwrite -i package.deb
# Corrupted package database
sudo dpkg --configure -a
# Check package integrity
debsums -c
debsums packagename
# Verify signatures
apt-key list
apt-key finger
Debugging Installation
# Verbose installation
sudo dpkg -i --debug=all package.deb
# Dry run
apt install --dry-run packagename
# Simulation
apt install -s packagename
# Log files
tail -f /var/log/dpkg.log
tail -f /var/log/apt/history.log
Security Considerations
Package Verification
# Check package signature
dpkg-sig --verify package.deb
# Verify checksums
sha256sum package.deb
md5sum package.deb
# Check repository signatures
apt-key verify /var/lib/apt/lists/*Release.gpg
Secure Package Creation
# Sign packages
dpkg-sig --sign builder package.deb
# Use secure build environments
sbuild -d unstable mypackage.dsc
# Reproducible builds
dpkg-buildpackage --build=source,all --no-sign
DEB packages provide a robust, secure, and efficient method for software distribution on Debian-based systems, offering comprehensive dependency management, configuration handling, and system integration capabilities that have made them a cornerstone of the Linux ecosystem.
File Information
Debian binary package
Package
.deb
application/vnd.debian.binary-package
Related File Types
Other file types in the Package category you might also need:
Start Analyzing DEB Files Now
Use our free AI-powered tool to detect and analyze Debian binary package files instantly with Google's Magika technology.
⚡Try File Detection Tool