Linux – See end-nodes of dependency graphs

arch linuxpackage-managementpacman

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?

Best Answer

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
}
Related Question