Managing packages with APT

Install, update and remove software on a Debian/Ubuntu VPS with APT, and avoid the common pitfalls.

Updated

Updating the package list

Before any installation, always refresh the list of available packages:

sudo apt update

This command updates nothing by itself: it simply refreshes the list of what's available in the configured repositories.

Updating installed packages

sudo apt upgrade

Updates every already-installed package to its latest available version, without removing or installing new packages.

Installing software

sudo apt install package-name

For instance, to install the Nginx web server:

sudo apt install nginx

Searching for a package

If you don't know a package's exact name:

apt search keyword

Removing a package

sudo apt remove package-name

Removes the software but keeps its configuration files. To remove everything including configuration:

sudo apt purge package-name

Cleaning up unused packages

Over time, dependencies installed automatically are no longer used by any active package:

sudo apt autoremove

upgrade vs dist-upgrade

apt dist-upgrade goes further than apt upgrade: it can install or remove packages if needed to resolve dependencies (useful in particular during a major system version change). Use it with more caution.

Can’t find your answer?

The team answers tickets seven days a week, and the Discord is open to everyone.