If you update your current Ubuntu or Debian kernel, then the old kernel image will remain installed on your hard drive, despite it is no longer needed or used. Also, if you do a frequent system update, then a heap of kernel files will be taking up much hard disk space without being in use.
In this guide we will help you rid your system of these unused kernel images using a single command from the terminal. The tip is workable for both Ubuntu and Debian-based systems.
1. You can check your current used kernel with this command:
2. To find a list of all installed kernels on your system, run this command:
dpkg --list | grep linux-image
3. To remove all unused kernels, run now this command:
sudo aptitude purge ~ilinux-image-\[0-9\]\(\!`uname -r`\)
- If "aptitude" is not installed, then install it with this command:
sudo apt-get install aptitude
4. Update now your Grub2 boot loader with this command:
[NOTE]: USE THESE TIPS AT YOUR OWN RISK!