How to remove old kernel versions on Ubuntu Server
It is recommended to remove old kernel version to clean up the boot menu and to get some extra disk space.
1. Check which kernel version you're using:
uname -r
2. List all installed kernels and headers on your system:
dpkg -l | grep linux-image
dpkg -l | grep linux-headers
3. If you're not using the latest kernel version, try rebooting your system first.
4. You can remove old kernel versions automatically:
sudo apt-get autoremove
5.a. Or you can remove them manually one by one:
sudo apt-get purge linux-image-x.x.x.x-generic
Be sure, NOT to remove the version you're using!
It is also recommended to leave the previous version on your system.
5.b. When you're done, update your Grub:
sudo update-grub2
6. Reboot your system.