When we install a package in most Linux distributions, the package system installs other packages needed by the package that we are installing. If we uninstall the package, its dependencies might not be uninstalled; these unused dependencies are called orphaned packages.

Let's see how to remove orphaned packages.

Archlinux

pacman -Rsn $(pacman -Qdtq)

How does the command work?

  • pacman -Qdt lists all orphaned packages
  • pacman -Rsn uninstalls the listed packages

Debian

apt-get remove --purge $(deborphan)