Ubuntu Server – Manually removing kernel packages

UPDATE: Looks like a one-liner was added to apt-get a few years back that simplifies the older and more manual way which I documented below. This also affects more than just the old kernels so use with caution:

apt-get autoremove --purge

After a number of kernel upgrades the file system gets filled up. Here is one way to clean up.

As root –

Display a list of installed kernel packages:

dpkg -l | grep linux-image

Display the running kernel (you don’t want to really remove this one do you?):

uname -a

After careful observation, remove the packages:

apt-get purge linux-image-3.2.0-23-generic, linux-image-3.2.0-24-generic

As a side, I tend to leave one additional kernel installed as a backup, unless there is a serious security/bug issue.