A Debian package is a binary software archive with the .deb extension that contains the files of a program together with the control metadata and maintainer scripts needed to install, configure, upgrade and remove it on Linux. In package management, the deb package is the native unit of distribution for Debian and its derivatives, including Ubuntu, Linux Mint and Raspberry Pi OS, and it is handled at the low level by dpkg and at the high level by APT.
The format matters because it turns software installation into a predictable, reversible transaction: the system knows which files belong to which package, which other packages are required, and which scripts must run at each stage. That bookkeeping is what allows thousands of packages to coexist and be upgraded together without manual tracking.
How a Debian package is structured
A .deb file is an ar archive containing three members in a fixed order. The first is a small text file named debian-binary that declares the format version, currently 2.0. The second is control.tar, which holds the metadata and scripts, and the third is data.tar, which holds the actual files to be unpacked into the filesystem.
Both tar members are usually compressed, most often with xz or zstd in modern releases and with gzip in older ones. Because the outer container is a plain ar archive, administrators can inspect a package with standard tools such as ar t or dpkg-deb --contents without installing anything.
The following table lists the members of a binary package and what each one contributes.
| Member | Typical content | Purpose |
|---|---|---|
| debian-binary | The string 2.0 | Declares the package format version |
| control.tar.xz | control, md5sums, conffiles, scripts | Metadata, checksums and lifecycle hooks |
| data.tar.xz | Files under /usr, /etc, /lib | Payload unpacked into the root filesystem |
Inside the control archive, the md5sums file records checksums for every installed file, which lets debsums or dpkg --verify detect modified or corrupted files after installation. The conffiles list marks configuration files that dpkg must preserve when the package is upgraded.
Control fields and maintainer scripts
The control file is a set of RFC 822 style fields that describe the package to the package management system. It names the package, its version, its architecture and, most importantly, its relationships with other packages, which APT uses to compute a consistent installation plan.
The table below summarizes the fields that most strongly influence installation behavior.
| Field | Example value | Effect on installation |
|---|---|---|
| Package | nginx-core | Unique name in the archive |
| Version | 1:1.24.0-2ubuntu1 | Epoch, upstream version and Debian revision |
| Architecture | amd64, arm64, all | Limits the package to matching systems |
| Depends | libc6 (>= 2.34) | Packages that must be configured first |
| Recommends | ca-certificates | Installed by default but not strictly required |
| Conflicts / Breaks | nginx-light | Prevents incompatible packages coexisting |
| Provides | httpd | Satisfies a virtual package name |
The version string follows a strict comparison algorithm. The optional epoch before the colon overrides all other parts, the upstream version comes next, and the Debian revision after the last hyphen tracks packaging changes. Misreading this order is a frequent cause of confusion when a locally built package unexpectedly loses to an older-looking archive version.
Maintainer scripts named preinst, postinst, prerm and postrm run at defined points of the lifecycle. They create system users, register services with systemd, update caches and clean up data. Because they run as root, a faulty maintainer script can leave a package half-configured, which dpkg reports as a broken state until the problem is fixed.
Debian packages compared with other formats
The Debian package is one of two dominant native package formats on Linux, the other being RPM. Universal formats such as Snap, Flatpak and AppImage solve a different problem: they bundle dependencies to run the same build across many distributions.
The comparison below places the .deb format next to its closest neighbors.
| Format | Main distributions | Dependency model | Isolation |
|---|---|---|---|
| Debian package | Debian, Ubuntu, Mint | Shared system libraries | None by default |
| RPM | Fedora, RHEL, openSUSE | Shared system libraries | None by default |
| Snap | Ubuntu and others | Bundled runtimes | AppArmor confinement |
| Flatpak | Desktop distributions | Shared runtimes | Bubblewrap sandbox |
| AppImage | Any distribution | Fully bundled | None by default |
The key trade-off is shared libraries versus bundling. A .deb relies on the distribution to supply compatible libraries, which keeps packages small and lets one security update fix every dependent program, but it ties a package to a specific release. Bundled formats travel better between distributions at the cost of larger downloads and duplicated libraries.
Building, installing and inspecting deb packages
Most deb packages are built from a source package, which consists of an upstream tarball, a debian/ directory with packaging instructions and a .dsc description file. Tools such as dpkg-buildpackage, debuild and sbuild compile the source in a controlled environment and produce one or more binary packages.
Day-to-day administration relies on a small set of commands, shown in the following table.
| Task | Command | Notes |
|---|---|---|
| Install a local file | apt install ./file.deb | Resolves dependencies from repositories |
| Install without resolution | dpkg -i file.deb | Fails if dependencies are missing |
| List package contents | dpkg-deb -c file.deb | Works without installing |
| Show control metadata | dpkg-deb -I file.deb | Displays fields and scripts |
| Find the owner of a file | dpkg -S /usr/bin/curl | Searches the installed database |
| Repair interrupted setup | dpkg –configure -a | Finishes pending configuration |
A practical rule is to prefer apt over dpkg for local files, because APT fetches missing dependencies automatically, while dpkg only unpacks the archive and stops when requirements are unmet. Packages from official repositories are additionally verified through signed Release files and GPG keys, a protection that a downloaded standalone .deb does not have.
Limitations and common mistakes
The .deb format is robust, but several recurring errors cause most real-world breakage. They usually come from mixing sources rather than from the format itself.
- Installing packages built for another release, which can pull in incompatible library versions and create a so-called FrankenDebian system.
- Adding untrusted third-party repositories or PPAs without reviewing what they replace, since their packages run maintainer scripts as root.
- Using dpkg –force options to bypass dependency errors, which hides the problem instead of solving it.
- Editing files owned by a package outside /etc, because the next upgrade silently overwrites them.
- Confusing remove with purge: remove keeps configuration files, while purge deletes them as well.
A further limitation is that a single installed version per package is the norm, so running two versions of the same library side by side requires separate package names, containers or a universal format.
In plain words
A Debian package is like a labeled shipping box for software. Inside are the program files, plus a packing slip that says what the program is called, which version it is and which other boxes it needs to work.
When a computer running Debian or Ubuntu installs the box, it reads the slip, fetches anything missing and puts every file in the right place. Because it keeps a record of everything it unpacked, it can later upgrade or remove the program cleanly without leaving scattered leftovers.
A real-world example
A small software company ships an internal monitoring agent to about 400 Ubuntu 22.04 servers. Instead of copying binaries by hand, the team builds a .deb that installs the agent under /usr/bin, places its configuration in /etc/monitor-agent/ as a conffile and uses a postinst script to create a system user and enable a systemd service.
The package declares Depends: libc6 (>= 2.35), libssl3, and the team publishes it in a private signed APT repository. Each server simply runs apt install monitor-agent, and later releases arrive through the normal apt upgrade cycle.
When administrators customize the configuration on some hosts, dpkg preserves their edits during upgrades and asks before replacing them. The result is a fleet that updates in minutes, with every file traceable through dpkg -S and clean removal with apt purge when a server is retired.