Skip to content

Instantly share code, notes, and snippets.

@mahfuzul
Created August 10, 2017 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahfuzul/b1eff5c8031cc9426a0e23e16d4018f3 to your computer and use it in GitHub Desktop.
Save mahfuzul/b1eff5c8031cc9426a0e23e16d4018f3 to your computer and use it in GitHub Desktop.
Ubuntu Cleanup: How to Remove All Unused Linux Kernel Headers, Images and Modules
##Ubuntu Cleanup: How to Remove All Unused Linux Kernel Headers, Images and Modules
#First check uname -a to check your current version.
#List Unused Linux Kernel Headers, Images and Modules
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'
sudo apt-get -y purge some-kernel-package
#List Unused Linux Kernel Headers, Images and Modules & Remove
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