I get fed up occasionally of the million…

I get fed up occasionally of the million and one old kernels I have installed after multiple updates and upgrades of my Ubuntu install, so I have the following shell script snippet to sort it out for me:

That pumps out a list of all the installed kernels and associated images/modules/etc apart from the one you are currently using. It also keeps around suffixed kernels at the same version as your current one (so if you have the -pae, -rt, -smp, -generic and -preempt kernels installed, it will leave the ones that match the version number of your current kernel).

Now, if you want to be dangerous and not check the output, you can bin them all with a single command, like so:

Et voila! Goodbye superfluous kernels!