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