APT (Debian/Ubuntu)
Install, update, remove and search for packages on Debian and Ubuntu with apt.
The basics
update refreshes the local package index from your configured repositories; it doesn't install anything by itself. Always run it before install or upgrade so you're not installing a stale version.
sudo apt update
sudo apt install nginx
sudo apt remove nginx
sudo apt purge nginx # also deletes its config filesSearching for a package
Not sure of the exact package name? search matches against names and descriptions.
apt search redis
apt show redis-server # details on a specific packageKeeping things tidy
autoremove drops packages that were pulled in as dependencies but are no longer needed by anything installed. autoclean clears out old downloaded .deb files from the local cache.
sudo apt autoremove -y
sudo apt autocleanapt vs apt-get
apt is the modern, user-facing command (better progress output, sane defaults) and is what these docs use throughout. apt-get is the older, more script-friendly interface β you'll still see it in tutorials and Dockerfiles, and the two are largely interchangeable for everyday use.