APT (Advanced Package Tool) is the high-level package management system of Debian, Ubuntu and their derivatives in Linux. It downloads packages from signed repositories, resolves dependencies and then hands the actual installation of .deb files to the low-level tool dpkg.
The name covers both a library, libapt-pkg, and a family of front ends: the interactive apt command, the script-oriented apt-get and apt-cache, and graphical tools built on the same library. Since its introduction in Debian in 1998, APT has become the standard way to install, upgrade and remove software on Debian-based systems.
How APT works on top of dpkg
APT splits package management into two layers. dpkg knows how to unpack a single .deb file, run its maintainer scripts and record it in the package database, but it does not fetch anything or resolve dependencies. APT adds the missing layer: it knows which repositories exist, which versions they offer and which combination of packages satisfies every dependency.
A typical operation runs in a fixed order: APT reads the local package indexes, computes a solution, downloads the required archives, verifies their checksums and then calls dpkg to unpack and configure them. The table below lists the main components and where they live.
| Component | Location | Role |
|---|---|---|
| Source lists | /etc/apt/sources.list.d/ | Define repositories, suites and components |
| Package indexes | /var/lib/apt/lists/ | Local copies of repository metadata |
| Archive cache | /var/cache/apt/archives/ | Downloaded .deb files |
| Preferences | /etc/apt/preferences.d/ | Pinning rules and version priorities |
| Extended states | /var/lib/apt/extended_states | Automatic versus manual install marks |
| dpkg database | /var/lib/dpkg/ | Actual installed state of every package |
Because APT works from local copies of metadata, apt update must refresh them before APT can see new versions. Installing without a recent update is a common cause of 404 errors, since the mirror has already replaced the old file names.
Core APT commands and their effect
The most important distinction among APT commands is whether an operation may remove packages. A regular upgrade never removes installed packages, while a full upgrade may remove them to resolve changed dependencies, which is why it is used for release upgrades.
| Command | What it does | May remove packages |
|---|---|---|
| apt update | Refreshes package indexes from all sources | No |
| apt upgrade | Upgrades installed packages, may add new dependencies | No |
| apt-get upgrade | Upgrades without installing any new packages | No |
| apt full-upgrade | Upgrades and resolves conflicts by removal | Yes |
| apt install pkg | Installs a package and its dependencies | Only if conflicts require it |
| apt autoremove | Removes unneeded automatic dependencies | Yes |
| apt-cache policy pkg | Shows candidate versions and priorities | No |
The apt front end is meant for people: it shows a progress bar, colors and a condensed summary, and its output format is not guaranteed stable. Scripts and configuration management tools should use apt-get and apt-cache, whose interfaces are kept backward compatible.
APT also tracks why each package is installed. Packages pulled in as dependencies are marked automatic, and apt autoremove deletes them once nothing depends on them; apt-mark manual protects a package from that cleanup.
Repositories, signatures and trust
Every APT repository is authenticated through a signed Release file. The InRelease file carries an OpenPGP signature and the SHA-256 hashes of every index file, and each index lists the hash of every package, so a single trusted key protects the whole chain down to individual .deb archives.
Modern systems describe repositories in the deb822 format in .sources files, which Debian 13 and Ubuntu 24.04 use by default. The current best practice binds each repository to its own key through the Signed-By field, replacing the deprecated global apt-key keyring that let any trusted key sign any repository.
| Field | Example value | Meaning |
|---|---|---|
| Types | deb deb-src | Binary packages, source packages or both |
| URIs | Mirror address over HTTP or HTTPS | Where APT downloads indexes and packages |
| Suites | trixie trixie-updates | Release or update channel |
| Components | main contrib non-free-firmware | Licensing or support sections |
| Signed-By | /usr/share/keyrings/debian-archive-keyring.gpg | Key allowed to sign this source |
Plain HTTP mirrors are acceptable precisely because of this design: integrity comes from signatures, not from the transport. HTTPS still adds confidentiality about which packages a host downloads.
Pinning and version priorities
When several sources offer the same package, APT chooses the candidate version by priority, not simply by the highest version number. Each source receives a default priority, and pinning rules in /etc/apt/preferences.d/ can override it per package or per release.
| Priority | Typical source | Effect |
|---|---|---|
| 1000 or more | Explicit pin | Installed even if it means a downgrade |
| 990 | Release set as default target | Preferred over other releases |
| 500 | Normal repository | Installed if the version is newer |
| 100 | Backports, installed version | Used only when requested or already installed |
| 1 | Experimental archive | Never chosen automatically |
| Below 0 | Blocking pin | Version is never installed |
This mechanism explains why Backports packages are not installed automatically: their archive is marked with a priority of 100, so a user must request them with apt install -t trixie-backports pkg. Running apt-cache policy is the quickest way to see which version APT will choose and why.
APT compared with other package managers
APT belongs to the same class as DNF and Pacman: high-level managers that resolve dependencies and fetch from repositories. dpkg and RPM are the corresponding low-level tools that only handle local package files.
| Tool | Level | Package format | Main distributions |
|---|---|---|---|
| APT | High-level | .deb | Debian, Ubuntu, Linux Mint |
| dpkg | Low-level | .deb | Same, used underneath APT |
| DNF | High-level | .rpm | Fedora, RHEL, Rocky Linux |
| RPM | Low-level | .rpm | Same, used underneath DNF |
| Pacman | Both in one tool | .pkg.tar.zst | Arch Linux |
Common APT mistakes
- Mixing releases by adding testing or another distribution’s repository without pinning, which produces a fragile system often called a FrankenDebian.
- Running
dpkg -ion a downloaded file and leaving unresolved dependencies;apt install ./file.debresolves them instead. - Interrupting an upgrade, which leaves packages half-configured until dpkg –configure -a finishes the job.
- Using
aptin scripts, where its unstable output and interactive prompts cause failures; useapt-get -yinstead. - Adding third-party keys to the global trust store instead of binding them with Signed-By.
In simple terms
APT works like an app store for a Linux computer, operated by typed commands. It keeps a catalog of available software, checks that every download really comes from the trusted publisher and installs everything a program needs to run.
If a photo editor needs three extra libraries, APT notices that, fetches all four pieces and sets them up in the right order. Later, a single update command brings every installed program up to date at once.
A practical example
An administrator maintains 40 Ubuntu 24.04 web servers. Each night, an automation job runs apt-get update followed by apt-get -y upgrade, so security fixes arrive within a day without any package being removed unexpectedly.
A new application needs a newer PostgreSQL client than the distribution ships. The administrator adds the vendor repository as a deb822 file with Signed-By pointing to its own key, and adds a pin of 600 limited to the client packages. apt-cache policy confirms that only those packages come from the vendor while everything else stays on Ubuntu. The upgrade rolls out across all 40 servers with no dependency conflicts and no unplanned changes to other packages.