Monday, 6 December 2010

How to remove Old Ubuntu Kernels in a single command.

On Ubuntu you amass a load of old kernels over time. There are a lot of guides on the net on how to remove kernels, but none of them give me the pithy and succinct one liner that just does the job in the least amount of keystrokes.

Or worse they remove something they shouldn't do.

Here's my entry as the easiest way to get rid of those kernels, without removing other packages. For those of a cautious disposition use 'search' instead of 'purge' to see the list of things that will be removed first :-)

sudo aptitude purge '~ilinux-image-[0-9].* !'`uname -r`