Remove Orphaned Packages with pacman -Rns $(pacman -Qtdq)
pacman -Qtdq lists dependency packages nothing depends on anymore; feeding that list to pacman -Rns cleans them up.
Run `pacman -Qtdq` to list orphan packages, then `sudo pacman -Rns $(pacman -Qtdq)` to remove them along with their now-unneeded dependencies.
01Command
Command
$ sudo pacman -Rns $(pacman -Qtdq)02What it does
Unlike Debian's autoremove or dnf autoremove, Arch has no single built-in orphan sweep — this query pipeline is the canonical ArchWiki recipe. -t filters to unrequired dependencies, -d relaxes version checks, -q prints bare names, and -Rns removes the packages recursively with configs. If the subshell is empty, pacman prints an error and changes nothing, so the command is safe to keep in a cleanup alias.
03Risk
!Warning: Review `pacman -Qtdq` before removing — occasionally a manually-installed dependency is marked as such and may still be wanted.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Pacman/Tips and tricks - ArchWikiEvidence: Documents removing unused packages (orphans): pacman -Qtdq lists orphans and pacman -Rns $(pacman -Qtdq) removes them.
- pacman(8) — package manager utilityEvidence: -Qtdq: -t lists packages installed as dependencies that are not required by any installed package, -d skips dependency versions, -q quiet output; -Rns removes packages with their dependencies and configs.
Last verified: 2026-09-17 · Category: System & Settings