Score:2

APT upgrades a package and then asks for removing it

br flag

I am using Ubuntu 20.04. During the last 4-5 times I've used upgrade APT always upgrades the following

  linux-headers-5.4.0-96 linux-headers-5.4.0-96-generic
  linux-image-5.4.0-96-generic linux-modules-5.4.0-96-generic
  linux-modules-extra-5.4.0-96-generic

when I use autoremove, it says that these same packages will be removed. I'm new to ubuntu and I'm not sure if I'm using these packages in my regular work. But I'd like to know what's going on here?

Possible duplicate.

Thanks!

Score:3
my flag

TL;DR

The current version of the Ubuntu GA kernel is 5.4-0-99. You're currently having the version 5.4-0-96. APT is recommending you to upgrade your kernel to the latest one (5.4-0-99). apt autoremove is suggesting you to remove the older version i.e (5.4-0-96).


Let's take the package linux-headers-5.4.0-96 as an example for understanding it better.

linux-headers-5.4.0-96 is a kernel package, the kernel package are different from the normal packages.

Generally, normal packages like aptitude and neofetch do not change their names when they are upgraded. Unlike normal packages, kernel packages change their name when they're upgraded. For example, linux-headers-5.4.0-96 will change its name to 5.4.0-99.

When a kernel gets upgraded, it comes in the form of a newer package instead of upgrading the older one. For instance, linux-headers-5.4.0-96 got upgraded to 5.4.0-99. Here, the name of the package linux-headers-5.4.0-96 changed to the version 5.4.0-99, thus, is considered as a different package by APT (Advanced Packaging Tool).

According to the developers and repositories, the package 5.4.0-99 is the upgraded version of linux-headers-5.4.0-96, so APT is forced to install it but it does not remove the older version of the package i.e, linux-headers-5.4.0-96.

So, APT is showing an upgrade is available for linux-headers-5.4.0-96. It won't remove the older version of the package as described above.

So, apt upgrade will upgrade the package to its newer version without removing the older one. But what about the older version of the package? Will it remain forever in your system? By default, Ubuntu keeps only the 2 latest kernels. If your system has more than 3 kernels or an obsolete kernel it would be removed by the apt autoremove command.

br flag
thanks for this ELI5, so if I understand correctly, if I use `autoremove` to get rid of `5.4.0-96` then the next time I will simply have `5.4.0-99` and that will be upgraded when an upgrade comes out?
Someone avatar
my flag
@pixis seems correct.
Score:3
sa flag

The current version of the Linux kernel in my updated Ubuntu 20.04 is 5.4.0-99. apt is offering you the option to upgrade your current kernel from version 5.4.0-96 to 5.4.0-99. By default Ubuntu keeps only the two latest installed kernels when you run sudo apt autoremove. If your Ubuntu has two or more kernel versions that are newer than 5.4.0-96 then sudo apt autoremove will remove the 5.4.0-96 kernel and it will also remove any installed kernels that are older than 5.4.0-96 if they are no longer needed.

The results of cat /var/log/apt/history.log on my Ubuntu 20.04 show that the Linux kernel was upgraded by apt upgrade from version 5.4.0-97 to 5.4.0-99 on 2022-02-08 and apt autoremove removed the 5.4.0-96 kernel the following day.

br flag
thanks for this response, this works. I'm accepting @Someone's answer because it is more elaborate.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.