Created
September 7, 2021 19:50
-
-
Save borestad/72a44265fa3fca3b8e6a2d1f5c0d783f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Cleaning Linux Headers" | |
#echo $(dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p') $(dpkg --list | grep linux-headers | awk '{ print $2 }' | sort -V | sed -n '/'"$(uname -r | sed "s/\([0-9.-]*\)-\([^0-9]\+\)/\1/")"'/q;p') | xargs sudo apt-get -y purge | |
#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 | |
echo "" | |
echo "Cleaning orphan .deb packages" | |
deborphan | xargs sudo apt-get -y remove --purge | |
echo "" | |
echo "Cleaning APT" | |
sudo apt-get -y autoremove | |
sudo apt -y autoclean | |
sudo apt -y clean | |
echo "" | |
echo "✔ Remove APT files" | |
find /var/lib/apt -type f | xargs rm -f | |
echo "✔ Clear cache" | |
find /var/cache -type f -exec rm -rf {} \; | |
echo "✔ Remove MAN files" | |
find /usr/share/man -iname '*.gz' | xargs rm -f | |
echo "✔ Remove DOC files" | |
find /usr/share/doc -iname '*.gz' | xargs rm -f | |
echo "✔ Remove INFO files" | |
find /usr/share/info -iname '*.gz' | xargs rm -f | |
echo "✔ Cleanup journal logs" | |
journalctl --rotate | |
journalctl --vacuum-time=1s | |
echo "✔ Cleanup /var/log/*" | |
truncate -s 0 /var/log/*.log | |
truncate -s 0 /var/log/**/*.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment