So you’ve been installing and removing packages on Arch, and now you want to clean up the leftovers. Let’s go step by step.
Remove a Package with Its Dependencies
If a package was installed normally via pacman, you can remove it along with the dependencies it pulled in like this:
sudo pacman -Rns <package name>
-R
→ remove package
-n
→ don’t back up configs (.pacsave
won’t be created)
-s
→ remove dependencies that are not required by anything else
Remove a Package + Config Files (Nuke It)
If you also want to remove the package’s configuration files (completely wipe it), add -c
:
sudo pacman -Rcns <package name>
⚠️ Warning: this is more risky — it will delete configs under /etc/...
and you won’t get them back.
List Orphan Packages
Orphaned packages are those no longer required by anything else. To list them:
pacman -Qdt
Q
→ query
d
→ list orphans
t
→ “not required by any package”
If you want to list just the package names (for scripting):
pacman -Qdtq
-q
→ just output names
With Yay
Since yay
is an AUR helper that wraps pacman, you can do the same:
yay -Qdt
yay -Qdtq
Remove Orphan Packages
To remove all orphaned packages at once:
sudo pacman -Rns $(pacman -Qdtq)
And with yay:
sudo pacman -Rns $(yay -Qdtq)
its so cool right ? 😀
Clean the Package Cache
Finally, you can free up some disk space by clearing cached packages that are no longer installed:
sudo pacman -Sc
If you want to go nuclear and wipe all cached packages (even the ones still installed), you can do:
sudo pacman -Scc
⚠️ Be careful — this means you won’t be able to downgrade packages easily.
Quick Reference Table
Command | What it does | Configs |
---|---|---|
-Rs | Remove package + deps, keep configs (creates .pacsave ) | Kept + backup |
-Rns | Remove package + deps, keep configs (no backup) | Kept |
-Rcns | Remove package + deps + configs (no backup) | Deleted |
Pro Tip
Before removing a package, you can check what would be removed without actually doing it:
pacman -Rcns <package-name> --print
This can save you from nuking half your desktop environment by mistake 😅.
🎉 That’s it! With these commands, you can keep your Arch install nice and clean.
Happy Arch-ing 😀
Leave a Reply