Remove old unused Linux kernel on Ubuntu

If you have been using your Ubuntu system for a long time and keep your system updated, you will end up with many Linux kernel versions installed on your Ubuntu system. During the Linux kernel update, older versions of the Linux kernel are not automatically removed. It stays in your system and eats some of your system space. You can use the following method to remove an old unused Linux kernel on your Ubuntu system.

Note: Keeping your old Linux kernel can be useful in troubleshooting current kernel issues. Also, keep at least one or two old kernels for troubleshooting or fallback.

Remove the old unused Linux kernel on Ubuntu.

Method 1:

Open a terminal and run this command. This is the easiest and safest method and will remove all unnecessary packages.

sudo apt autoremove --purge

Method 2:

You can also manually remove the old kernel in the terminal. However, be careful. First, use this command to list all kernels installed on your system.

Recommended article: How to install Howl on Ubuntu-a lightweight keyboard-centric text editor

List all installed Linux kernels.

dpkg -l | grep linux-image | awk '{print$2}'

You can use this command to count the total number of installed Linux kernel files.

sudo dpkg --list | egrep -i --color 'linux-image|linux-headers' | wc -l

Next, execute the following command to check the version of the Linux kernel that is currently running.

Note: Do not remove the current Linux kernel.

uname -r

Important: Do not remove your current Linux kernel.

Run the following command to remove the specific kernel and configuration files. If you want to remove “linux-image-4.10.0-20-generic”, run:

sudo apt remove --purge linux-image-4.10.0-20-generic

Then update the grub2 settings

sudo update-grub2

And finally reboot the system.

sudo reboot

You can also use the Synapse Package Manager and Ubuntu software to remove the old Linux kernel.

If you like this article, please subscribe to us Youtube channel.. You can also stay connected with us twitter And Facebook..

It’s a sequel.


Related Posts