Last active
December 31, 2023 10:46
-
-
Save R3tr0BoiDX/a177b79e920bea0a6d695e36a1efff45 to your computer and use it in GitHub Desktop.
Clean your system!
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 | |
RED="\e[31m" | |
ENDCOLOR="\e[0m" | |
sudo -v | |
echo -e "${RED}Run auto clean${ENDCOLOR}" | |
sudo apt autoclean -y | |
echo -e "${RED}Run auto remove${ENDCOLOR}" | |
sudo apt autoremove -y | |
while true; do | |
echo -e "${RED}Purge orphan packages${ENDCOLOR}" | |
sudo apt purge $(deborphan) -y | |
read -p "Do you want to repeat purging orphans? (Y/n): " choice | |
case $choice in | |
y|Y ) | |
continue | |
;; | |
n|N ) | |
break | |
;; | |
* ) | |
echo "Invalid choice. Please enter 'y' or 'n'." | |
;; | |
esac | |
done | |
echo -e "${RED}Purge previous removed packages${ENDCOLOR}" | |
sudo aptitude purge -y ~c | |
echo -e "${RED}Remove unused flatpaks${ENDCOLOR}" | |
sudo flatpak uninstall --unused | |
echo -e "${RED}Removes old revisions of snaps${ENDCOLOR}" | |
set -eu | |
LANG=C snap list --all | awk '/disabled/{print $1, $3}' | | |
while read snapname revision; do | |
sudo snap remove "$snapname" --revision="$revision" | |
done | |
echo -e "${RED}Clear snap cache${ENDCOLOR}" | |
sudo sh -c 'rm -rf /var/lib/snapd/cache/*' | |
echo "Cleared snap cache" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment