Skip to content

Instantly share code, notes, and snippets.

@zhaostu
Created October 20, 2012 03:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhaostu/3921939 to your computer and use it in GitHub Desktop.
Save zhaostu/3921939 to your computer and use it in GitHub Desktop.
One-liner to remove old Linux kernels in Ubuntu
## Note: This is only tested in the latest Ubuntu distributions.
## Please make sure packages to be removed are correct.
## http://stuzhao.blogspot.com/2012/10/remove-old-linux-kernels-in-ubuntu.html
dpkg -l | awk '{print $2}' | grep "linux-\(image\|headers\)-[0-9]" | grep -v `uname -r | sed s/-generic//` | xargs sudo apt-get purge -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment