Skip to content

Instantly share code, notes, and snippets.

@wangyingang
Last active August 29, 2015 13:58
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 wangyingang/10026417 to your computer and use it in GitHub Desktop.
Save wangyingang/10026417 to your computer and use it in GitHub Desktop.
Ubuntu cleanup. Remove All Unused Linux Kernel Headers, Images and Modules

Remove All Unused Linux Kernel Headers, Images and Modules

list all installed kernels

dpkg --list | grep linux-image

clean up

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

if you’ve upgraded your system, or had an update with a new kernel, please reboot your machine before running above the command

update grub

sudo update-grub2 

All done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment