Skip to content

APT

20 commands

Debian and Ubuntu’s package manager: install, update, search and remove software and inspect package sources.

  • packages
  • Debian
  • Ubuntu

Installing5

sudo apt update

Refreshes the package lists from the configured repositories. Run this before installing or upgrading.

Link
sudo apt install <package>

Installs a package and its dependencies.

Link
sudo apt install --no-install-recommends <package>

Skips recommended extras to keep the system lean.

Link
sudo apt install ./<file>.deb

Installs a local .deb and resolves its dependencies.

Link
sudo apt reinstall <package>

Reinstalls a package, restoring modified files.

Link

Upgrading and removing6

sudo apt upgrade

Upgrades installed packages without removing any.

Link
sudo apt full-upgrade

Upgrades and allows removals when dependencies change.

Link
apt list --upgradable

Shows pending upgrades.

Link
sudo apt remove <package>

Removes a package but keeps its configuration.

Link
sudo apt purge <package>

Removes a package and its configuration.

Link
sudo apt autoremove

Removes dependencies no longer needed.

Link

Querying7

apt search <term>

Searches package names and descriptions.

Link
apt show <package>

Version, size, dependencies and description.

Link
apt list --installed

Every installed package.

Link
apt-cache policy <package>

Installed and candidate versions and which repository each comes from.

Link
dpkg -L <package>

Files installed by a package.

Link
dpkg -S <path>

Which package owns a file.

Link
dpkg --verify

Reports installed files whose checksums no longer match the package — a quick integrity check after a compromise.

Link

Holding2

sudo apt-mark hold <package>

Pins a package at its current version.

Link
apt-mark showmanual

Packages that were installed explicitly rather than as dependencies.

Link