clean up /boot (for Ubuntu at least)

Here is a quick set of commands to clean up the /boot partition on an Ubuntu linux system.

First check what your kernel version is  so you won’t delete the running kernel image:

uname -r

Now run this for a list of installed kernels:

dpkg --list 'linux-image*' | grep ^ii

delete the kernels you don’t want/need anymore by running this:

sudo apt-get remove linux-image-Ver

Replace the “Ver” with the version(s) of the kernel(s) you want to remove.

Finally, run this to update the grub kernel list:

sudo update-grub