Pacman Guide for Arch Linux
Basic Package Management
Search for a package in the repositories.
shellsudo pacman -Ss <package-name>
Install a package from the repositories.
shellsudo pacman -S <package-name>
Install a package from a .pacman file.
shellsudo pacman -U <file-name.pacman>
Check if a package is installed.
shellpacman -Qs <package-name>
Reinstall an installed package.
shellsudo pacman -S <package-name> --needed --noconfirm
Package Removal
Remove a package, keep dependencies and configuration files.
shellsudo pacman -R <package-name>
Remove a package and its unused dependencies, keep configuration files.
shellsudo pacman -Rs <package-name>
Remove a package, unused dependencies, and configuration files.
shellsudo pacman -Rns <package-name>
Remove a package and all packages that depend on it, keep unused dependencies.
shellsudo pacman -Rc <package-name>
Forcefully remove a package without checking dependencies (dangerous).
shellsudo pacman -Rdd <package-name>
Advanced (Aggressive) Removal
Nuclear Option: Remove the package, configuration files, unused dependencies, and dependent packages.
shellsudo pacman -Rnsc <package-name>
Tsar Bomb: Forcefully remove the package, dependencies, and dependent packages. Ignores dependency checks (highly dangerous).
shellsudo pacman -Rnscdd <package-name>
System Maintenance
Update the local mirror list.
shellsudo pacman -Syy
Update the system (sync package database and install updates).
shellsudo pacman -Syu
Force refresh of mirrors and system update.
shellsudo pacman -Syyu
Check for available updates (without applying them).
shellsudo pacman -Qu
Show orphaned packages (packages not required by any other package).
shellpacman -Qdt
Remove orphaned packages.
shellsudo pacman -Rns $(pacman -Qdtq)
Check package integrity (to find missing or corrupted files).
shellpacman -Qkk
Package Information and Logs
Show detailed information about an installed package.
shellpacman -Qi <package-name>
List files installed by a package.
shellpacman -Ql <package-name>
List all installed packages.
shellpacman -Q
List explicitly installed packages (ignores dependencies).
shellpacman -Qe
List manually installed (AUR) packages.
shellpacman -Qm
Cache Management
Delete cached packages, keep the most recent versions.
shellsudo pacman -Sc
Delete the entire package cache.
shellsudo pacman -Scc
Clear old package versions while keeping the last 3 versions.
shellsudo paccache -r
List cached package files.
shellsudo ls /var/cache/pacman/pkg/
Keyring and Troubleshooting
Reinstall and update Pacman’s keyring.
shellsudo pacman -Sy archlinux-keyring
Remove Pacman database lock (useful when you encounter a locked database).
shellsudo rm /var/lib/pacman/db.lck
Forcibly reinstall all installed packages (useful for fixing many broken packages).
shellsudo pacman -S $(pacman -Qq) --needed
Other Useful Commands
List files that don't belong to any package.
shellpacman -Qk | grep "no package owns"
Clean Pacman log, keeping only the last 1000 lines.
shellsudo tail -n 1000 /var/log/pacman.log > /var/log/pacman.log