Cleaning up old kernels (command line)

I manage some headless (command line) servers, so I need a way to remove old kernels without a GUI. I haven’t written a script to do it yet, since I don’t do it more than once or twice a year.

Find the currently running kernel:

uname -r

Get the list of kernels:

dpkg –list ‘linux-image*’

Delete old ones with:

sudo apt-get remove linux-image-#OLD_VERSION_TO_DELETE#

Now clean up:

sudo apt-get autoremove

And update GRUB

sudo update-grub

 

Comments are closed, but trackbacks and pingbacks are open.