system cleaning
cleaning packages
- Check the size of the package cache:
du -sh /var/cache/pacman/pkg/
Removing packages
i. Remove uninstalled packages from the cache:
sudo pacman -Sc yay -Scii. Remove all cached packages except for the most recent three versions of each package:
sudo pacman -S pacman-contrib sudo paccache -riii. Remove all cached packages:
sudo pacman -Scc yay -Scciv. Remove orphaned packages (packages that were installed as dependencies but are no longer required by any installed package):
to list them :
pacman -Qdtto remove them:
sudo pacman -Rns $(pacman -Qtdq)
cleaning journal logs
- Check the size of journal logs:
journalctl --disk-usage
Clean journal logs:
i. Remove journal logs older than a specific time period (e.g., 2 weeks):
sudo journalctl --vacuum-time=2weeksii. Limit the size of journal logs to a specific size (e.g., 500M):
sudo journalctl --vacuum-size=500MNote: for more options, you can refer to the
man journalctlpage and edit/etc/systemd/journald.conffile to set persistent storage and size limits.
clean system temporary files and user cache
- Clean system temporary files:
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*
- Clean user cache:
rm -rf ~/.cache/*
places to look out
~/.config/– where applications stores their configuration~/.cache/– cache of some programs may grow in size~/.local/share/– old files may be lying there~/.streamio-server/– cache of streamio applications
other useful tools
gdu- A disk usage analyzer with a terminal user interface.paccache from pacman-contrib- A utility to manage the package cache of pacman.tmpwatch- A utility to remove files that haven’t been accessed for a specified period of time.bleachbit- A graphical tool to clean unnecessary files and free up disk space.fdupes- A command-line tool to find and remove duplicate files.rmlint- A tool to find and remove duplicate files and other lint on the filesystem.localepurge (AUR)- A tool to remove unnecessary locale files and free up disk space.
automate pacman cleaning
- Systemd timer create file in /etc/systemd/system/paccache.timer
[Unit]
Description=Clean-up old pacman pkg cache
[Timer]
OnCalendar=monthly
Persistent=true
[Install]
WantedBy=multi-user.target
- enable
sudo systemctl enable paccache.timer
sudo systemctl start paccache.timer