← Knowledge Base
DebianReference note1 min read · updated 2026-11-27

apt: install, update, remove and inspect packages

The daily apt commands on Debian and Ubuntu, including what is installed and where a file came from.

aptpackagesdebian
sudo apt update                      # refresh the package lists
sudo apt upgrade                     # install available updates
sudo apt full-upgrade                # also allow removing/installing packages to resolve changes
sudo apt install nginx
sudo apt remove nginx                # keep configuration files
sudo apt purge nginx                 # remove configuration too
sudo apt autoremove                  # remove no-longer-needed dependencies
apt search keyword
apt show nginx                       # details and dependencies
apt list --installed | grep nginx
dpkg -L nginx                        # files a package installed
dpkg -S /usr/sbin/nginx              # which package owns a file
apt policy nginx                     # candidate and installed versions

Use apt-mark hold <pkg> to stop one package from being upgraded. The low-level tool is dpkg -i file.deb; fix missing dependencies afterwards with sudo apt -f install.