Skip to content

apt command

Install, update and remove packages on Ubuntu and Debian.

On this page

Syntax

apt [options] command [package…]

Provided by the apt package. Run man apt for the full manual.

Common options

OptionWhat it does
updateRefresh the package lists
upgradeUpgrade installed packages
full-upgradeUpgrade, adding or removing packages if needed
installInstall packages
removeRemove packages, keep config
purgeRemove packages and config
autoremoveRemove unused dependencies
searchSearch package names and descriptions
showPackage details
list --installedInstalled packages
-yAnswer yes to prompts

Examples

  1. Refresh the package lists

    sudo apt update
  2. Upgrade everything

    sudo apt update && sudo apt upgrade -y
  3. Install a package

    sudo apt install nginx
  4. Install a local .deb file

    sudo apt install ./package.deb
  5. Remove a package

    sudo apt remove apache2
  6. Remove with its config

    sudo apt purge apache2
  7. Clean unused dependencies

    sudo apt autoremove
  8. Search for a package

    apt search redis
  9. Show package details

    apt show php8.4
  10. List installed packages

    apt list --installed
  11. List available upgrades

    apt list --upgradable

apt guides

← All Linux commands · Suggest a fix

Back to top