Skip to content

Instantly share code, notes, and snippets.

@OsamaShabrez
Forked from rugbyprof/clean_unused_kernels
Created November 27, 2019 08:32
Show Gist options
  • Save OsamaShabrez/c7bd584a51ccaf4a2d473e6c370ec376 to your computer and use it in GitHub Desktop.
Save OsamaShabrez/c7bd584a51ccaf4a2d473e6c370ec376 to your computer and use it in GitHub Desktop.
Ubuntu Cleanup: How to Remove All Unused Linux Kernel Headers, Images and Modules
//Credit goes to - http://ubuntugenius.wordpress.com
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment