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

How to revert back to X11 / Xorg from Wayland

Wayland is intended as a “simpler replacement for X”, and is getting quite a bit of hype around the Linux community. So much so, that it’s the default in the latest versions of Fedora, GNOME, KDE and others. While Wayland may be the future, it really is in future. At least for Ubuntu 17.10. The […]

Read More

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

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.