Basic notes and commands/scripts to help ease the cleanup process of your Arch Linux installation.
One of the big pros of using Arch Linux is obviously the reduced bloat on your system, as you are obviously the sole proprietor of such bloat.
However, just as a large software project that gets developed on constantly, we end up with technical debt - and when using your Arch system as a daily driver, you will probably acquire a certain amount of such "bloat debt" over the years.
This small Gist serves as your guide to get rid of such bloat, cached/unused/orphaned packages, old config files, dangling docker images and what have you.
So take out an hour or two of your calendar and make yourself some coffee, and read on.
https://wiki.archlinux.org/title/System_maintenance#Clean_the_filesystem
You can check the size of your home cache to get a sense of the potential savings with:
du -hs ~/.cache
Feel free to delve down into individual cache folders, as some of them are obviously very handy to keep, if you are actively using their cached data.
Using the paccache
utility, you can easily cleanup old cached packages. The following command will cleanup all cached packages, but still keep the last version (so you can still easily downgrade a version, if your recent installation of a package broke something).
paccache -rk1
Optionally, you can also not keep any old versions (-rk0
), or keep the last 3 (which is the default of paccache
).
You can list all the unused packages by:
pacman -Qtdq
Remember that you might still be using some of these packages, so I would definitely recommend checking through the list before removing these packages. Or you can just remove everything and re-install them when needed.
To remove all of these packages:
pacman -Qtdq | pacman -Rns -
If you have the expac
utility installed, you can get your top 50 largest packages easily with:
expac -HM '%m %n' | sort -h | tail -50
Check through these packages, and inspect their dependencies and which other packages depend on them by using pacman -Qi <package>
.
https://wiki.archlinux.org/title/Systemd/Journal#Journal_size_limit
Check for dangling or old images, these can obviously take up a lot of space - make sure to double-check with your containers and Dockerfiles you are actively using, of course.
docker images
docker image prune
You can also use the -a
flag to remove all images not referenced by any container:
If you are using VirtualBox or other virtual machine applications such as VMWare, check for old or otherwise unused virtual machines