I'm using Arch Linux, with its Pacman package manager. I want to keep my system as clean as possible, and that includes not having any unused packages installed. But, because of dependencies, it's not a trivial task to have zero of such, at least with my level of knowledge. Is there any tool available, console or GUI, that will show me all installed packages that nothing depends on?
3 Answers
From the Arch Wiki:
To list all packages no longer required as dependencies (orphans):
$ pacman -Qdt
Or, to recursively remove orphans:
orphans() { if [[ ! -n $(pacman -Qdt) ]]; then echo "No orphans to remove." else sudo pacman -Rs $(pacman -Qdtq) fi } - 2I don't trust scripts when it comes to deleting ;P Anyway, thanks.Xirdus– Xirdus2012-12-04 22:10:21 +00:00Commented Dec 4, 2012 at 22:10
- 3Fair enough: pacman will print a list of the packages for deletion, seeking your confirmation; so it is not entirely Russian Roulette...jasonwryan– jasonwryan2012-12-04 22:11:55 +00:00Commented Dec 4, 2012 at 22:11
pacman -Qt prints packages whose doesn't need on system (maybe you need it). I hope I didn't misunderstand you.
- 3The
-tswitch displays packages that are not required by another package, but this will obviously include stand-alone packages; you should combine it with the-dswitch for a better picture of "orphaned" packages--which is what I assume the OP means by "unused packages."jasonwryan– jasonwryan2012-12-04 21:49:54 +00:00Commented Dec 4, 2012 at 21:49 - I know but it wasn't unequivocal for me what Xirdus wants.uzsolt– uzsolt2012-12-05 09:37:04 +00:00Commented Dec 5, 2012 at 9:37
You usually want to see a list of end-user programs you have installed:
pacman -Qte where t lists the end nodes of the dependency graph (the packets not required by other installed packets) and e filters out only explicitly installed packages.
If you always forget what these programs are for (like I do), try:
pacman -Qtei | grep -P "Name|Description" After uninstalling, use
pacman -Rs $(pacman -Qqtd) To remove all orphan packages
Last idea taken from Pacman Tips.