Advanced Package Tool (APT) is a package manager for Unix-like computer systems that facilitates the retrieval, configuration and installation of software packages. APT is used by Debian-based Linux distributions, such as Ubuntu, Pop!_OS, Linux Mint, etc.
dpkg (Debian Package) is a low-level tool, at the base of the package management system. APT is a higher-level tool, which is more commonly used than dpkg as it can fetch packages from remote locations and automatically manage package dependencies, etc.
I am most familiar with Dandified Yum (DNF), which is an alternative package manager for RPM packages. This is due to my history with Fedora, which uses DNF/RPM by default.
However, in recent weeks, I have switched to Pop!_OS, which is Ubuntu-based and therefore uses APT.
Similar to my “DNF Cheat Sheet” article, the goal of this article is to highlight common APT commands (acting as a cheat sheet).
Before proceeding, it is important to understand the difference between a repository and a package.
- A repository containers packages.
- A package contains an application.
Repositories and packages simplify software distribution and installation.
List All Repositories
The following command will list all repositories checked by APT.
List All Packages
The following command will list all packages from installed repositories.
List Installed Packages
The following command will list all installed packages.
apt list --installed
The following command will install a specific package.
sudo apt-get install <package-name>
The following command will remove a specific package.
sudo apt-get remove <package-name>
Remove Package and Configuration
The following command will remove a specific package and the related configuration.
sudo apt-get --purge remove <package-name>
Remove Orphen Packages
The following command will remove any packages that are no longer required.
sudo apt-get --purge autoremove
Check for Updates
The following command will update the list of available packages and their versions, but it does not install or upgrade any packages. The “update” command should be run before the “upgrade” command.
sudo apt-get update
Upgrade All Packages
The following command will upgrade installed packages. The “update” command should be run before the “upgrade” command.
sudo apt-get upgrade
View Package Information
The following command will show the details of a specific package.
apt show <package>
Additional information regarding APT can be found on the Ubuntu documentation.