To remove all unused old kernels on Ubuntu 18.04, you can use the following steps:
dpkg -l | grep linux-imageSource:www.lautturi.com
This will list all of the Linux kernel images that are installed on your system.
Identify the kernels that you want to remove. The kernel that is currently running is indicated by the *
character in the output of the above command. You should not remove the currently running kernel.
Uninstall the kernels that you want to remove using the apt-get
command. For example, to remove the kernel with package name linux-image-4.15.0-101-generic
, you can run the following command:
sudo apt-get remove linux-image-4.15.0-101-generic
Repeat this process for each kernel that you want to remove.
sudo apt-get autoremove
This will remove any unnecessary dependencies that are no longer needed after the kernels were removed.
sudo update-grub
This will update the boot menu to remove any entries for the kernels that you removed.
Keep in mind that removing kernels can be risky, as it is possible that the currently running kernel may have a bug or issue that you are unaware of. If this is the case, removing the kernel may cause your system to become unstable. It is always a good idea to make a backup of your system before removing any important packages.