Skip to content

Instantly share code, notes, and snippets.

@cpjobling
Created July 18, 2014 09:33
Show Gist options
  • Save cpjobling/8c78c45a7130ace7f199 to your computer and use it in GitHub Desktop.
Save cpjobling/8c78c45a7130ace7f199 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Remove old images from Ubuntu and clean up /boot and grub.
#
# Original Source: [Ubuntu Cleanup: How to Remove All Unused Linux Kernel Headers, Images and Modules](http://ubuntugenius.wordpress.com/2011/01/08/ubuntu-cleanup-how-to-remove-all-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' | xargs sudo apt-get -y purge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment