keeping your storage tidy with pacman

pacman is a lovely--and decently fast--package manager, used by arch linux. nothing beats apk in speed though :P

table of contents

clean stale cache

after verifying all your stuff is in working order, this is safe to run

pacman -Sc

cleaning ALL cache

this one will leave you regretting you did this if a package breaks in the future, though in my experience and despite arch's reputation, that will happen quite rarely.

pacman -Scc

removing no longer required dependencies

this is somewhat akin to apt autoremove

pacman -Qttdq | pacman -Rns -

keeping kernel modules

when the kernel gets updated without rebooting, it will no longer be easy to load new kernel modules, as the directory of old modules gets automatically deleted.

the Extra kernel-modules-hook (github) package resolves this by creating a hook that keeps old kernel modules.

somewhat hacky

these might break and are of questionable quality.

list largest non-dependencies

breaks if you have a package or a field with a capital letter N.
pacman -Qtti | grep 'Name\|Installed Size' | tr "\n" " " | tr "N" "\n" | awk '{print $3 " " $7 $8}' | sort -k2 -h