Does sudo apt list --upgradeable show kernel updates?
I was wondering whether
sudo apt list --upgradeable
shows kernel updates in the list or not?
Yes it does. After you run sudo apt-get update
, if there's a kernel update, then apt list --upgradeable
should show some packages like linux-headers-4.4.0-something
and linux-image-4.4.0-something
.
Only the updated kernel metapackages are typically shown in the output of apt list --upgradeable
.
Nearly all kernel updates are provided as new packages, rather than as new versions of existing packages, so you can keep your old kernels for a while in case the update breaks something and you need to boot the system with an older kernel. These are the packages that have version numbers in their names, like linux-image-4.15.0-60-generic
.
In order to make it so you receive such packages updates, there are kernel metapackages that server the sole purpose of declaring the packages that actually provide the kernel as dependencies. When new kernel packages are released, the metapackages are themselves updated to depend on it.
Those metapackages show as upgradeable in the output of apt list --upgradeable
, which is correct because you already have them installed and a new version is available. The new packages are not listed here, because you don't have them yet. As pbojczuk observed, those packages are not going to be upgraded, they're going to be installed.
It's possible for those packages to appear in the output of apt list --upgradeable
, but rare. This could happen if an update were issued to fix a problem that doesn't change the kernel itself. For example, if there were a bug in the installation or removal scripts for a package that provides kernel files, the fix for that bug would likely be provided as an update to that package, not as a separate kernel package with a version in the name.
You can see what will actually be done by running apt -s upgrade
.
After running sudo apt update
to retrieve information about what packages are available from where and in what versions, running apt list --upgradeable
lists the metapackages but not the packages that actually provide the new kernel and associated files:
ek@Kip:~$ apt list --upgradeable
Listing... Done
linux-generic/bionic-proposed 4.15.0.60.62 i386 [upgradable from: 4.15.0.59.61]
linux-headers-generic/bionic-proposed 4.15.0.60.62 i386 [upgradable from: 4.15.0.59.61]
linux-image-generic/bionic-proposed 4.15.0.60.62 i386 [upgradable from: 4.15.0.59.61]
linux-libc-dev/bionic-proposed 4.15.0-60.67 i386 [upgradable from: 4.15.0-59.66]
If you want to see everything that would be installed by running sudo apt upgrade
without actually running it, you can tell apt
to run a simulation, using apt -s upgrade
:
ek@Kip:~$ apt -s upgrade
NOTE: This is only a simulation!
apt needs root privileges for real execution.
Keep also in mind that locking is deactivated,
so don't depend on the relevance to the real current situation!
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
linux-headers-4.15.0-60 linux-headers-4.15.0-60-generic linux-image-4.15.0-60-generic
linux-modules-4.15.0-60-generic linux-modules-extra-4.15.0-60-generic
The following packages will be upgraded:
linux-generic linux-headers-generic linux-image-generic linux-libc-dev
4 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Inst linux-modules-4.15.0-60-generic (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [i386])
Inst linux-image-4.15.0-60-generic (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [i386])
Inst linux-modules-extra-4.15.0-60-generic (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [i386])
Inst linux-generic [4.15.0.59.61] (4.15.0.60.62 Ubuntu:18.04/bionic-proposed [i386]) []
Inst linux-image-generic [4.15.0.59.61] (4.15.0.60.62 Ubuntu:18.04/bionic-proposed [i386]) []
Inst linux-headers-4.15.0-60 (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [all]) []
Inst linux-headers-4.15.0-60-generic (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [i386]) []
Inst linux-headers-generic [4.15.0.59.61] (4.15.0.60.62 Ubuntu:18.04/bionic-proposed [i386])
Inst linux-libc-dev [4.15.0-59.66] (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [i386])
Conf linux-modules-4.15.0-60-generic (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [i386])
Conf linux-image-4.15.0-60-generic (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [i386])
Conf linux-modules-extra-4.15.0-60-generic (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [i386])
Conf linux-generic (4.15.0.60.62 Ubuntu:18.04/bionic-proposed [i386])
Conf linux-image-generic (4.15.0.60.62 Ubuntu:18.04/bionic-proposed [i386])
Conf linux-headers-4.15.0-60 (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [all])
Conf linux-headers-4.15.0-60-generic (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [i386])
Conf linux-headers-generic (4.15.0.60.62 Ubuntu:18.04/bionic-proposed [i386])
Conf linux-libc-dev (4.15.0-60.67 Ubuntu:18.04/bionic-proposed [i386])
This isn't the only way to do it, but when you want to find out what an upgrade will do before performing it, it's the way I suggest. The output is usually very easy to understand, and because it may reveal other unexpected effects of the upgrade you're about to do.
The output I showed is from a machine on which the -proposed
repositories are enabled and new kernels are installed from them. (Note that this isn't usually a good idea on production machines, because those kernels are not fully tested on Ubuntu quite yet.) But you'll see similar output with fully stable kernel packages provides in -security
or -updates
.
Actually I do not see kernel packages via apt list --upgradable
. Compare:
apt list --upgradable | wc -l
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
141
Against:
apt --recon upgrade | grep ^Inst | wc -l
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
145
And the latter value is matching the upgrade result when I check the log /var/log/apt/history
and calculate values for the Install:
and Upgrade:
rows. The kernel packages are placed in Install:
row there.