How to Install and Manage Packages with apt
The apt command installs and manages software on Debian and Ubuntu. sudo apt install nginx downloads and installs nginx with one command. This guide covers the handful of apt operations you will use constantly, from searching to removing.
Update the package list first
Before installing or upgrading, refresh apt's list of available packages with apt update. It does not install anything — it just syncs the catalogs so later commands know what exists.
Search for a package
Not sure of the exact package name? apt search looks through names and descriptions.
Install a package
Install with apt install. apt resolves dependencies automatically and asks for confirmation. Answer y or pass -y to skip the prompt.
Upgrade installed packages
apt upgrade brings every installed package up to date. It is the routine maintenance step after running apt update. For kernel upgrades that can remove packages, use apt full-upgrade.
Remove and clean up
Uninstall with apt remove. Add --purge to also delete config files, or use apt autoremove to drop orphaned dependencies no package uses anymore.
On Arch Linux the equivalent tool is pacman. See apt for more.
Keep learning
Related guides: Install Software on Arch Linux with pacman · How to Schedule Tasks in Linux with cron · How to Check Open Ports with ss and netstat. Read all tutorials on the Learn Linux blog.