Skip to content

Instantly share code, notes, and snippets.

@benzerbett
Last active May 30, 2022 08:46
Show Gist options
  • Save benzerbett/c03f3fbaf1a5942d340cd01e21d44175 to your computer and use it in GitHub Desktop.
Save benzerbett/c03f3fbaf1a5942d340cd01e21d44175 to your computer and use it in GitHub Desktop.
System cleanup script for Ubuntu, Elementary etc
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
flatpak uninstall --unused
journalctl --rotate
journalctl --vacuum-time=1s
apt autoclean -y
apt autoremove --purge -y
apt-get clean -y
sudo find /tmp -type f -atime +10 -delete
rm -rf ~/.cache/thumbnails/*
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
npm cache clean --force
yarn cache clean
pip cache purge
pip3 cache purge
go clean -modcache
docker image prune -f
docker image prune -a -f
docker rmi $(docker images -f "dangling=true" -q)
@Injiri
Copy link

Injiri commented Dec 9, 2021

docker rmi $(docker images -f "dangling=true" -q) so helpfull

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment