System maintenance on Arch Linux

Also see index_linux.

All information you need is essentially on the arch wiki, e.g. pacman tips and tricks. But here are some things I typically forget and want to have ready in one place.

Disk usage

Check current file usage per partition in a human readable format:

df -h

Check if you can remove large unused packages

LC_ALL=C pacman -Qi | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -h

Then manually remove large unused packages and their dependencies pacman -Rs [package].

Checking disk usage per folder

du: disk usage.

By default this lists everything. Start at root and investigate iteratively which folder is largest to identify where you should clean up. Sort by file size with sort -h. The -h flag is needed to handle the human readable output from du -h:

sudo du -h --max-depth=1 | sort -h

Clean Trash and Downloads folder

Located under ~/.local/share/Trash/

So empty with:

rm -rf ~/.local/share/Trash/*
rm -rf ~/Downloads/*

Clean pacman cache

Check the disk size of /var/cache/pacman/. At the moment of writing, mine grew 60Gb in size! It's handy to have some packages in cache because you can then easily downgrade to older version of packages, but we do not need to save everything.

There's a dedicated tool to clean up the cache, but keep the most recent package versions for downgrading. This saved 43Gb for me! :-O

paccache -r

Check journal

We don't need to keep a journal of everything necessarily, depending on the context. On my home computer I don't need extensive journals. We can inspect the current usage with:

journalctl --disk-usage

We can make sure the journal is cleanup after 3 days with:

sudo journalctl --vacuum-time=3d

This saved 2.7 Gb for me!

Temporary files

TODO check if they are automatically removed for me at shutdown. I have several gigs in my temp folder.