This is an old revision of the document!
To find out the current version of Linux kernel running on your system, use the following command.
$ uname -sr
Linux 4.12.0-041200-generic
To list all installed kernels on your system, issue this command.
$ dpkg -l | grep linux-image | awk '{print$2}'
linux-image-4.12.0-041200-generic
linux-image-4.8.0-22-generic
linux-image-extra-4.8.0-22-generic
linux-image-generic
Run the commands below to remove a particular linux-image along with its configuration files, then update grub2 configuration, and lastly reboot the system.
$ sudo apt remove --purge linux-image-4.4.0-21-generic $ sudo update-grub2 $ sudo reboot
And that's it. However, Although this method works just fine, it is more reliable and efficient to use a handy script called “byobu” that combines all the commands above into a single program with useful options such as specifying number of kernels to keep on the system.
Install byobu script package which provides a program called purge-old-kernels used for removing old kernels and header packages from the system.
$ sudo apt install byobu
Then remove old kernels like so (the command below allows 2 kernels to be kept on the system).
$ sudo purge-old-kernels --keep 2