clear-root-1.sh 681 B

12345678910
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. # # I successfully cleared 3.5 GB by removing old headers and images.
  4. # # Please note on some systems this also attempts to remove the current kernel which is not a great idea - see comments below for how to check.
  5. # # I used the following command:
  6. # 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
  7. # You can check what packages will be purged executing the first part of the command:
  8. dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'