Basic commands
Install & update
Install a package.
pacman -S <package>
Update and upgrade. They must be done at the same time.
pacman -Syu
pacman -Syyu ## Force a repository update/sync
Uninstall
Uninstall a package.
pacman -R <package>
pacman -Russ <package>
--remove
-R
removes packages, keeps config files appending ".pacsave"--nosave
-n
deletes config files.--unneeded
-u
removes unneeded dependencies.--recursive
-s
remove all of the dependencies that are not required by other packages and they were not explicitly installed. Twice to include explicitly installed.
Search
Search for a package.
pacman -Ss <package>
Query
List packages
pacman -Q
List packages installed from repositories
pacman -Qn
List packages not installed from repositories
pacman -Qm
List orphaned packages
pacman -Qdt
List explicitly installed packages
pacman -Qe
pacman -Qet
List all files installed by a package
pacman -Ql
Remove packages that are no longer installed from the cache as well as currently unused sync databases to free up disk space.
pacman -Sc
Clean
Clean all cached versions of installed and uninstalled packages up to the last 3 versions (pacman-contrib)
paccache -r
Clean up to one past version (pacman-contrib)
paccache -rk1
Clean all the uninstalled packages from cache (pacman-contrib)
paccache -ruk0
Uninstall orphaned packages
sudo pacman -Rns $(pacman -Qqdt)
Add a package as explictly installed so is not considered an orphan.
pacman -D --asexplicit <pkgs>
Query files
Search which packages installed a file
pacman -F /path/to/file
Search for a package that will install a program
pacman -Fy # Update the cache
pacman -Fq htpasswd
Downgrade
Downgrade a package from the ones in the local cache.
pacman -U /var/cache/pacman/pkg/package-old_version.pkg.tar.xz
Downgrade a package with downgrade
(AUR)
downgrade <package name>
Other
Reinstall all packages
pacman --force -S "$(pacman -Qqen)"
Receive keys. Keys can be found in the signature of a package, it redirects to a key server with the ID of the key.
sudo pacman-key --recv-keys 0x7A4E76095D8A52E4
/etc/pacman.conf
VerbosePkgLists
Before
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...
Packages (10) acpi_call-lts-1.1.0-90 dnssec-anchors-20190629-1 lib32-libdrm-2.4.99-1 libdrm-2.4.99-1 linux-lts-4.19.57-1
linux-lts-headers-4.19.57-1 mpc-0.32-1 mpd-0.21.11-1 tzdata-2019b-1 yubikey-personalization-1.20.0-1
Total Download Size: 84.96 MiB
Total Installed Size: 195.92 MiB
Net Upgrade Size: -0.07 MiB
:: Proceed with installation? [Y/n] ^C
Interrupt signal received
After
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...
Package (10) Old Version New Version Net Change Download Size
community/acpi_call-lts 1.1.0-89 1.1.0-90 0.00 MiB 0.01 MiB
core/dnssec-anchors 20181003-1 20190629-1 0.00 MiB 0.00 MiB
multilib/lib32-libdrm 2.4.98-1 2.4.99-1 0.00 MiB 0.13 MiB
extra/libdrm 2.4.98-1 2.4.99-1 0.01 MiB 0.24 MiB
core/linux-lts 4.19.56-1 4.19.57-1 0.00 MiB 74.87 MiB
core/linux-lts-headers 4.19.56-1 4.19.57-1 0.00 MiB 8.45 MiB
extra/mpc 0.31-1 0.32-1 -0.03 MiB 0.17 MiB
extra/mpd 0.21.10-1 0.21.11-1 -0.04 MiB 0.70 MiB
core/tzdata 2019a-1 2019b-1 -0.01 MiB 0.33 MiB
community/yubikey-personalization 1.19.3-1 1.20.0-1 0.00 MiB 0.06 MiB
Total Download Size: 84.96 MiB
Total Installed Size: 195.92 MiB
Net Upgrade Size: -0.07 MiB
:: Proceed with installation? [Y/n]