Chris Titus wrote an article (and did a video!) about cleaning Arch Linux. I wanted to add a bit more that I find helpful – something that he didn’t cover: Uninstalling UNUSED dependencies!
He covered cleaning the pacman cache, pruning timeshifts, checking usage and several other things, but not removing orphaned dependencies. Here’s a great little one liner to do just that:
sudo pacman -Rsn $(pacman -Qdtq)
A quick explanation of what you’re doing:
The inner $(pacman -Qdtq)
fetches the list of orphaned dependencies that were explicitly installed but are no longer required, setting the result of the output to a variable passed to the outer pacman -Rsn
command.
- -Q: Query
- -d: Filter packages installed as dependencies
- -t: Filter un-required packages not (optionally) required by any other package
- -q: format results in a less verbose manner for passing to another command
The outer pacman -Rsn
- -R: Remove a package.
- -s: Recursively remove dependencies no longer needed by any other installed package.
- -n: Avoid keeping backup copies of the configuration files, making the removal more thorough.
As always, don’t just blindly run commands from the internet. Go validate what you just read on the Arch Wiki. I hope this helps! 🙂