apt cheat sheet
This cheat sheet helps becoming more fluent with the apt command, the package manager used on Linux systems running Debian, Ubuntu, and others.
Basic usage
These are common subcommands to be used together with apt:
Command | Intended action |
---|---|
autoremove | Clean up packages that are no longer needed |
install PACKAGE | Install package |
search PATTERN | Search for available package according to the pattern |
purge PACKAGE | Remove the remainders after removing a package |
remove PACKAGE | Remove package, leave custom configurations |
show PACKAGE | Provide information about a package |
update | Refresh the repository data |
upgrade | Pull in and install upgrades for packages that are installed |
Common options include:
Long | Short | Action |
---|---|---|
--download-only | -d | Just download a package, do not install |
--quiet | -q | Silent operation |
--simulate | -s | Perform simulation, no actual actions |
--yes | -y | Perform ‘yes’ to prompts, automating actions |
Information about packages
See which packages are available that start with ’nginx’ with the list subcommand and really quiet output.
# apt -qq list nginx*
nginx-common/jammy-updates 1.18.0-6ubuntu14.4 all
nginx-confgen/jammy 2.0-1 amd64
nginx-core/jammy-updates 1.18.0-6ubuntu14.4 amd64
nginx-doc/jammy-updates 1.18.0-6ubuntu14.4 all
nginx-extras/jammy-updates 1.18.0-6ubuntu14.4 amd64
nginx-full/jammy-updates 1.18.0-6ubuntu14.4 amd64
nginx-light/jammy-updates 1.18.0-6ubuntu14.4 amd64
nginx/jammy-updates 1.18.0-6ubuntu14.4 amd64
Show information of a single package to learn what it does, its dependencies, size, and other possible relevant information.
apt show nginx
Installed packages
See all installed packages with the list subcommand and --installed option.
apt list --installed
Installation of packages
Installation happens with the subcommand install followed by the package.
apt install nginx
Install a local .deb file is also possible.
apt install myfile.deb
Upgrading packages
Refresh the repository to pull in the latest available information of the underlying databases.
apt update
See packages that have a newer version (upgrade):
apt list --upgradable
Install available upgrades:
apt upgrade
Related tools
Use apt-file to see to which package a file belongs or what files are provided by a package.