You might find it more often than not when you run apt-get or
apt on Ubuntu or Debian systems you get the message; The following packages were automatically installed and are no longer required. This is then followed with a list of packages the instruction; “Use ‘sudo apt autoremove’ to remove them”. In this short guide, we will use apt-get in our explanations to mean apt as well.
Here is what a typical message looks like:
The following packages were automatically installed and are no longer required: linux-headers-5.4.0-89-generic linux-headers-5.4.0-90-generic linux-hwe-5.4-headers-5.4.0-89 linux-hwe-5.4-headers-5.4.0-90 linux-image-5.4.0-89-generic linux-image-5.4.0-90-generic linux-modules-5.4.0-89-generic linux-modules-5.4.0-90-generic linux-modules-extra-5.4.0-89-generic linux-modules-extra-5.4.0-90-generic php8.0-dev Use 'sudo apt autoremove' to remove them.
This happens as a side effect of a package or multiple packages being installed automatically by apt-get because it’s a dependency of some other package. apt-get keeps track of it. Later on, when
apt-get notices that nothing depends on the package anymore, it will suggest that the package be removed. That is what “no longer required” means.
If you want to prevent this behavior on certain packages you can run apt-mark on it and mark it as manually installed for example:
$ sudo apt-mark manual git
You can also install it explicitly. If it is already installed, it may be upgraded to the latest release otherwise it won’t do anything other than mark it as manually or explicitly installed and won’t suggest their removal.
$ sudo apt-get install git
Conclusion, is “No Longer required” Safe?
Yes, You have seen it is, therefore, totally safe to run the command to remove the specified packages and keep your Ubuntu and Debian-based systems tidy.