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.
| Command | What it does |
|---|---|
apt update | updates package lists from the repositories; installs nothing |
apt upgrade | installs new versions of installed packages |
apt full-upgrade | the same, but removes packages when necessary |
apt install nginx | installs a package together with its dependencies |
apt remove nginx | removes a package; purge also removes its system-wide configuration files |
apt autoremove | removes dependency packages that are no longer needed by anything |
apt search, apt show | search for a package by description and show details about it |
apt list --upgradable | lists packages that have new versions available |
apt update && apt upgrade -yRepositories 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.
Types: debURIs: http://deb.debian.org/debianSuites: trixieComponents: mainSigned-By: /usr/share/keyrings/debian-archive-keyring.gpgEach 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 --upgradableshows the list of updates,apt upgradeinstalls them.- The
unattended-upgradesservice 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 -sperforms a dry run that changes nothing on the system.
Sources
the term is written from these pages- man apt(8) — Debianmanpages.debian.org/trixie/apt/apt.8.en.html(opens in a new tab)
- man sources.list(5) — Debianmanpages.debian.org/trixie/apt/sources.list.5.en.html(opens in a new tab)
- Debian FAQ — The Debian package management toolsdebian.org/doc/manuals/debian-faq/pkgtools.en.html(opens in a new tab)
Verified 9 Nov