DevOps Zone is brought to you in partnership with:

Graduated in computer science at the University of Oldenburg, Germany. Develops software for over 20 years now. Likes to program in Java. Wrote and contributed Maven plugins and implemented initially Maven support for IntelliJ IDEA. Ralf is a DZone MVB and is not an employee of DZone and has posted 18 posts at DZone. You can read more from them at their website. View Full User Profile

Remove All Unused Ubuntu Kernel Images, Headers, and Modules

01.10.2013
| 1448 views |
  • submit to reddit

Seeing that my linux box is running low on free space I decided to remove all unused Linux kernel images on my Ubuntu 10.04 system.

For some unknown reason Ubuntu Tweak refused to install properly so I decided to go a different way and used the command from this blog article.

The command mentioned in the blog is:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge 

If you don't understand what this command does I recommend to dig into the topic. I must admit it is a little bit complex, but the command is working well.

Use it at your own risk!

Now my system is cleaned up and still boots the correct and latest kernel. All other kernel images, headers and modules are completely removed.

Published at DZone with permission of Ralf Quebbemann, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)