After upgrading to the latest linux kernels, the old kernels will remain until they are manually removed. Here is how it can be done:
As a first step, open linux terminal (Ctrl + Alt + T)
Execute the following command:
$ uname -r
example output:
4.15.0-96-generic
It will display the current kernel running on your linux distribution. We should be aware of the current version, when executing commands to delete the other (older) kernels.
You can see the number of installed kernels by executing the following command:
$ sudo dpkg --list | egrep -i --color 'linux-image|linux-headers' | wc -l
Example output:
171
When they are more than 10, I delete the older kernels. It’s a great way to free some space on disk.
Get List of Kernels
Execute the following command:
$ dpkg --list | grep linux-image
Example output:
rc linux-image-4.15.0-74-generic 4.15.0-74.84 amd64 Signed kernel image generic
rc linux-image-4.15.0-76-generic 4.15.0-76.86 amd64 Signed kernel image generic
rc linux-image-4.15.0-88-generic 4.15.0-88.88 amd64 Signed kernel image generic
ii linux-image-4.15.0-91-generic 4.15.0-91.92 amd64 Signed kernel image generic
ii linux-image-4.15.0-96-generic 4.15.0-96.97 amd64 Signed kernel image generic
ii linux-image-generic 4.15.0.96.87 amd64 Generic Linux kernel image
Manually Remove Old Kernel
Then you can manually remove some of the old kernel versions by executing the following commands:
$ sudo apt-get purge linux-image-4.15.0-74-generic
$ sudo dpkg --purge linux-headers-4.15.0-74 linux-headers-4.15.0-74-generic