Bookmarks

APT — APT package manager

Advanced Package Tool

The system package manager of Debian and Ubuntu: it installs, updates and removes software from repositories and resolves dependencies automatically.

Also: apt-get, apt command

checked 9 Nov

All terms

APT is the standard way to install and update software on Debian, Ubuntu and their derivatives: it downloads ready-made packages from the configured sources, verifies their signatures and pulls in dependencies. For a server administrator it is also the main channel of security updates.

Commands: apt and apt-get

APT has several command-line interfaces. apt-get and apt-cache are specialised commands that preserve backwards compatibility, which is why they are used in scripts. Since Debian 8, common operations have also been available through a separate apt command: it is intended as an interface for humans, and its behaviour is not guaranteed to stay stable between versions.

CommandWhat it does
apt updateupdates package lists from the repositories; installs nothing
apt upgradeinstalls new versions of installed packages
apt full-upgradethe same, but removes packages when necessary
apt install nginxinstalls a package together with its dependencies
apt remove nginxremoves a package; purge also removes its system-wide configuration files
apt autoremoveremoves dependency packages that are no longer needed by anything
apt search, apt showsearch for a package by description and show details about it
apt list --upgradablelists packages that have new versions available
bashA typical server update: lists first, then the packages themselves
apt update && apt upgrade -y

Repositories and signatures

The low-level work — unpacking files and configuring the package — is done by dpkg: higher-level tools such as APT build on it, working out the dependencies themselves and deciding where to fetch packages from and in what order. Package sources are listed in /etc/apt/sources.list and in files in the /etc/apt/sources.list.d directory. The modern format is .sources files with Types, URIs and Suites fields: a repository is described by separate fields rather than one long line full of spaces.

textAn example repository entry in the deb822 format
Types: debURIs: http://deb.debian.org/debianSuites: trixieComponents: mainSigned-By: /usr/share/keyrings/debian-archive-keyring.gpg

Each release of a repository comes with signed index files: APT checks the signature against the built-in keys and refuses to install packages from an unsigned or modified repository. This is why third-party sources should be added with care: a signed repository with a single package gains the right to replace files on the system.

Security updates

  • apt list --upgradable shows the list of updates, apt upgrade installs them.
  • The unattended-upgrades service installs security updates without human involvement; in Debian it is usually already installed, but it is worth checking that it is enabled.
  • Security updates are published in a separate repository suite, <release>-security (for example, trixie-security), so there is no need to wait for the next release of the distribution.
  • Before installing large updates in production, check which packages they will affect: apt upgrade -s performs a dry run that changes nothing on the system.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • APTAdvanced persistent threat

    The same APT abbreviation: in security it refers to a targeted, long-term attack, while the package manager is about Debian and Ubuntu.

In depth in the references

where the topic is covered in detail