Ubuntu / Linux news and application reviews.

If you've installed Ubuntu Karmic since it's Beta like me, you probably have a lot of unused Linux Kernel headers, images and modules. Actually, even if you did a fresh install of the final version, you should have a few of those which you no longer use.

We've posted this command before in a larger post (and I forgot about it), but I've remembered it today when I had realized I have ~500 MB of packages which I could remove to free up some space, so I wanted to share it again with you.

Remove Unused Linux Kernel Headers, Images And Modules With One Command


To remove all the unused Linux Kernel headers, images and modules, simply run this command:
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