Ubuntu: Cleanup Old linux-headers And linux-image Packages

The command

# dpkg --get-selections| grep -E "linux-(header|image).*3." | grep -iw install | sort

lists the current installed linux-(image|headers) packages:

linux-headers-3.2.0-30-generic install
linux-headers-3.2.0-30 install
linux-headers-3.2.0-31-generic install
linux-headers-3.2.0-31 install
linux-headers-3.2.0-32-generic install
linux-headers-3.2.0-32 install
linux-image-3.2.0-30-generic install
linux-image-3.2.0-31-generic install
linux-image-3.2.0-32-generic install

On my system I will just keep the current and the one before that:

# apt-get remove --purge 3.2.0-30

It will remove the packages

  • linux-headers-3.2.0-30*
  • linux-headers-3.2.0-30-generic*
  • linux-image-3.2.0-30-generic*

BTW. Found this info in another blog, but cannot remember where nor when, sorry …