Below is a “cheat sheet” style list of useful Arch Linux pacman commands that I use frequently (some from time to time). Some of those commands require root permission, hence will require sudo on most systems. The meaning of the used command switches is easiest looked up directly in the pacman manual.
If you are new to Arch and pacman then I strongly recommend you to at first take a look at pacman and pacman tips and tricks in the Arch wiki.
Upgrade, install, uninstall packages
Upgrade all packages on the system:
pacman -Syu
Install packages and all their required dependencies (and also upgrade all packages on the system):
pacman -Syu <pkg1> <pkg2>
Uninstall packages and all their unneeded dependencies (will fail if those packages are themselves required by other packages):
pacman -Rs <pkg1> <pkg2>
[Not recommended] Uninstall packages and force-uninstall all packages that depend on them:
pacman -Rsc <pkg1> <pkg2>
Remove cached old versions of installed packages (otherwise kept locally indefinitely):
paccache -r
Package database
Update the local package database = list of available packages from the remote package database (doesn’t upgrade any installed packages):
pacman -Sy
Force an update of the complete local package database from the remote package database (e.g. in case the local package database got corrupted):
pacman -Syy
Search the local package database with a regex:
pacman -Ss <regex>
Show info about a package in the local package database:
pacman -Si <pkg>
Installed packages
Query installed packages for an exact package name:
pacman -Q <pgk>
Search installed packages with a regex:
pacman -Qs <regex>
List all explicitly installed = manually user installed packages:
pacman -Qe
List packages that don’t have other packages depend on them (also not optionally depend):
pacman -Qtt
List packages that don’t have other packages depend on them (ignore optionally depend):
pacman -Qt
List all explicitly installed packages from the core, extra, and community repositories, that are not dependencies of other packages:
pacman -Qettn
List all explicitly installed packages from the AUR that are not dependencies of other packages:
pacman -Qettm
Show general info about installed packages:
pacman -Qii <pkg1> <pkg2>
List files that belong to given packages:
pacman -Ql <pkg1> <pkg2>
List the packages that are the owners of given files:
pacman -Qo <file1> <file2>
Show tree of packages that a given package depends on:
pactree <pkg>
Show tree of packages that depend on a given package:
pactree -r <pkg>