inside the mind of a linux admin

Ubuntu: How to delete all of your old kernels

Erik

Friday, March 7, 2014

ubuntu linux

No Comment

In Ubuntu 11.10 and newer versions, GRUB2 will display all kernels installed on your system at boot time. If you’re like me, you probably get annoyed with a lengthy list of out of date kernels to scroll through in your GRUB boot menu.

Let’s be real, no one really wants to boot a kernel from last year with bugs and vulnerabilities when you have nice new shiny kernels to choose from. Thankfully, the latest versions of GRUB2 installed in Ubuntu automatically display the latest kernel and hides the older kernels that you may have installed.

But what if you’re not using the latest GRUB?

No problem.

This will remove ALL versions but the current:

sudo apt-get remove –purge $(dpkg -l ‘linux-*’ | sed ‘/^ii/!d;/'”$(uname -r | sed “s/\(.*\)-\([^0-9]\+\)/\1/”)”‘/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d’)

WARNING: Use at your own risk, I am not responsible if you change or break something.

Related Posts

ScreenCloud: Troubleshooting missing Python modules after updates

One of my favorite tools that I find myself using quite often is called “ScreenCloud“. It allows you to quickly select any area of your workspace, create an sized screen shot, and then upload it or export it off to their server, your Dropbox account or an SFTP server. If you’ve recently performed upgrades, either […]

Read More

My Lenovo laptop thinks the pipe key is a > character

So, those that know me know I have a few laptops. I’m no stranger to technology. Imagine my chagrin when I try piping a linux command to grep and my output comes out like so: ps uawx > grep X I know that the ps command thinks it is superior to grep, but seriously. WTF […]

Read More

Leave a Reply

Your email address will not be published. Required fields are marked *

Twitter: kireguy

Tweeter button Facebook button Myspace button