APT - Advanced Packaging Tool

Updated: 2019-04-23

Apt can be considered a front-end to dpkg.

apt is a simplified command that combines the most commonly used command options from apt-get and apt-cache.

apt update vs apt upgrade vs apt dist-upgrade

apt update will only check the latest versions of the packages, without actually downloading package updates; apt upgrade will do the actual upgrading; while apt dist-upgrade is for upgrading the OS itself.

apt list

List all installed packages:

$ apt list --installed

List all packages with a newer version

$ apt update
$ apt list --upgradable


Get stats of the packages:

$ apt-cache stats
Total package names: 56529 (1,131 k)
Total package structures: 68831 (3,855 k)
  Normal packages: 44112
  Pure virtual packages: 983
  Single virtual packages: 5517
  Mixed virtual packages: 533
  Missing: 17686
Total distinct versions: 48580 (3,498 k)
Total distinct descriptions: 44673 (1,072 k)
Total dependencies: 320937 (8,986 k)
Total ver/file relations: 49432 (1,186 k)
Total Desc/File relations: 44673 (1,072 k)
Total Provides mappings: 10663 (213 k)
Total globbed strings: 120 (1,361 )
Total dependency version space: 1,598 k
Total slack space: 42.4 k
Total space accounted for: 17.8 M

Get package names:

$ apt-cache pkgnames  | grep ruby2

$ dpkg -l

Specify Version

$ apt-get install <package>=<version>