clean.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh -eux
  2. # Delete all Linux headers
  3. dpkg --list \
  4. | awk '{ print $2 }' \
  5. | grep 'linux-headers' \
  6. | xargs apt-get -y purge;
  7. # Remove specific Linux kernels, such as linux-image-3.11.0-15-generic but
  8. # keeps the current kernel and does not touch the virtual packages,
  9. # e.g. 'linux-image-generic', etc.
  10. dpkg --list \
  11. | awk '{ print $2 }' \
  12. | grep 'linux-image-.*-generic' \
  13. | grep -v `uname -r` \
  14. | xargs apt-get -y purge;
  15. # Delete Linux source
  16. dpkg --list \
  17. | awk '{ print $2 }' \
  18. | grep linux-source \
  19. | xargs apt-get -y purge;
  20. # delete docs packages
  21. dpkg --list \
  22. | awk '{ print $2 }' \
  23. | grep -- '-doc$' \
  24. | xargs apt-get -y purge;
  25. # Delete X11 libraries
  26. apt-get -y purge libx11-data xauth libxmuu1 libxcb1 libx11-6 libxext6;
  27. # Delete obsolete networking
  28. apt-get -y purge ppp pppconfig pppoeconf;
  29. # Delete oddities
  30. apt-get -y purge popularity-contest installation-report command-not-found command-not-found-data friendly-recovery;
  31. apt-get -y autoremove;
  32. apt-get -y clean;
  33. # Remove docs
  34. rm -rf /usr/share/doc/*
  35. # Remove caches
  36. find /var/cache -type f -exec rm -rf {} \;
  37. # delete any logs that have built up during the install
  38. find /var/log/ -name *.log -exec rm -f {} \;