List packages that can be upgraded in Ubuntu
April 18, 2021 ‐ 3 min read
Whether it is your local machine or a production server, it is good practice to keep the packages on your system up-to-date. To just see which packages can be updated you can use the commands apt upgrade --dry-run
and apt list --upgradable
. The former shows which packages should have been upgraded once you run apt upgrade
. The latter lists all the packages that can be upgraded.
You can do a dry-run as follows:
$ apt upgrade --dry-run
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
mysql-client mysql-server
The following packages will be upgraded:
google-chrome-stable libjs-underscore libpci3 pciutils
4 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Inst google-chrome-stable [89.0.4389.114-1] (89.0.4389.128-1 Google:1.0/stable [amd64])
Inst pciutils [1:3.6.4-1] (1:3.6.4-1ubuntu0.20.04.1 Ubuntu:20.04/focal-updates [amd64]) []
Inst libpci3 [1:3.6.4-1] (1:3.6.4-1ubuntu0.20.04.1 Ubuntu:20.04/focal-updates [amd64])
Inst libjs-underscore [1.9.1~dfsg-1] (1.9.1~dfsg-1ubuntu0.20.04.1 Ubuntu:20.04/focal-security [all])
Conf google-chrome-stable (89.0.4389.128-1 Google:1.0/stable [amd64])
Conf pciutils (1:3.6.4-1ubuntu0.20.04.1 Ubuntu:20.04/focal-updates [amd64])
Conf libpci3 (1:3.6.4-1ubuntu0.20.04.1 Ubuntu:20.04/focal-updates [amd64])
Conf libjs-underscore (1.9.1~dfsg-1ubuntu0.20.04.1 Ubuntu:20.04/focal-security [all])
And list the upgradable packages like:
$ apt list --upgradable
Listing... Done
google-chrome-stable/stable 89.0.4389.128-1 amd64 [upgradable from: 89.0.4389.114-1]
libjs-underscore/focal-security,focal-security 1.9.1~dfsg-1ubuntu0.20.04.1 all [upgradable from: 1.9.1~dfsg-1]
libpci3/focal-updates 1:3.6.4-1ubuntu0.20.04.1 amd64 [upgradable from: 1:3.6.4-1]
mysql-client/focal-updates,focal-updates,focal-security,focal-security 8.0.23-0ubuntu0.20.04.1 amd64 [upgradable from: 5.7.30-1ubuntu18.04]
mysql-server/focal-updates,focal-updates,focal-security,focal-security 8.0.23-0ubuntu0.20.04.1 amd64 [upgradable from: 5.7.30-1ubuntu18.04]
pciutils/focal-updates 1:3.6.4-1ubuntu0.20.04.1 amd64 [upgradable from: 1:3.6.4-1]
If you are looking for a specific package you can pipe the output to the grep
command.
apt list --upgradable | grep "mysql"
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
mysql-client/focal-updates,focal-updates,focal-security,focal-security 8.0.23-0ubuntu0.20.04.1 amd64 [upgradable from: 5.7.30-1ubuntu18.04]
mysql-server/focal-updates,focal-updates,focal-security,focal-security 8.0.23-0ubuntu0.20.04.1 amd64 [upgradable from: 5.7.30-1ubuntu18.04]
No need to pay too much attention to the warning in this case :-).