Pacman Cheatsheet This article provides a cheatsheet for using the Pacman package manager on Arch Linux. It covers commands for installing, removing, and updating packages, including options for handling optional dependencies, package groups, and regex patterns. The guide also explains how to query package databases and warns that partial system upgrades are not supported. Note that packages often have a series of optdepends - optional dependencies - which are packages that provide additional functionality to the application, albeit not strictly required for running it. When installing a package, pacman will list its optional dependencies among the output messages, but they will not be found in pacman.log: use the pacman -Si see Querying package databases command to view the optional dependencies of a package, together with short descriptions of their functionality. ⚠️ Partial upgrades are not supported 69 To install a single package or list of packages including dependencies , issue the following command: $ pacman -S package name1 package name2 ... To install a list of packages with regex: pacman -S $ pacman -Ssq package regex Sometimes there are multiple versions of a package in different repositories, e.g. core and testing . To install the former version, the repository needs to be defined in front: pacman -S core/package name To install a number of packages sharing similar patterns in their names – not the entire group nor all matching packages; eg. plasma: pacman -S plasma-{desktop,mediacenter,nm} Of course, that is not limited and can be expanded to however many levels needed: pacman -S plasma-{workspace{,-wallpapers},pa} Some packages belong to a group of packages that can all be installed simultaneously. For example, issuing the command: pacman -S plasma will prompt you to select the packages from the plasma group that you wish to install. Sometimes a package group will contain a large amount of packages, and there may be only a few that you do or do not want to install. Instead of having to enter all the numbers except the ones you do not want, it is sometimes more convenient to select or exclude packages or ranges of packages with the following syntax: Enter a selection default=all : 1-10 15 which will select packages 1 through 10 and 15 for installation, or: Enter a selection default=all : ^5-8 ^2 which will select all packages except 5 through 8 and 2 for installation. To see what packages belong to the plasma group, run: pacman -Sg plasma Note that if a package in the list is already installed on the system, it will be reinstalled even if it is already up to date. This behavior can be overridden with the --needed option. To remove a single package, leaving all of its dependencies installed: pacman -R package name To remove a package and its dependencies which are not required by any other installed package: pacman -Rs package name To remove a package, its dependencies and all the packages that depend on the target package this operation is recursive, and must be used with care since it can remove many potentially needed packages : pacman -Rsc package name To remove a package, which is required by another package, without removing the dependent package: pacman -Rdd package name pacman saves important configuration files when removing certain applications and names them with the extension .pacsave. To prevent the creation of these backup files use the -n option: pacman -Rn package name Note that pacman will not remove configurations that the application itself creates for example “dotfiles” in the home folder . ⚠️ Partial upgrades are not supported 69 pacman can update all packages on the system with just one command. This could take a while depending on how up-to-date the system is. The following command synchronizes the repository databases and updates the system’s packages, excluding “local” packages that are not in the configured repositories: pacman -Syu pacman queries the local package database with the -Q flag, the sync database with the -S flag and the files database with the -F flag. See pacman -Q --help, pacman -S --help and pacman -F --help for the respective suboptions of each flag. pacman can search for packages in the database, searching both in packages’ names and descriptions: pacman -Ss string1 string2 ... Sometimes, -s's builtin ERE Extended Regular Expressions can cause a lot of unwanted results, so it has to be limited to match the package name only; not the description nor any other field: pacman -Ss ^vim- To search for already installed packages: pacman -Qs string1 string2 ... To search for package file names in remote packages: pacman -Fs string1 string2 ... To display extensive information about a given package: pacman -Si package name For locally installed packages: pacman -Qi package name Passing two -i flags will also display the list of backup files and their modification states: pacman -Qii package name To retrieve a list of the files installed by a package: pacman -Ql package name To retrieve a list of the files installed by a remote package: pacman -Fl package name To verify the presence of the files installed by a package: pacman -Qk package name Passing the k flag twice will perform a more thorough check. To query the database to know which package a file in the file system belongs to: pacman -Qo /path/to/file name To query the database to know which remote package a file belongs to: pacman -Fo /path/to/file name To list all packages no longer required as dependencies orphans : pacman -Qdt To list all packages explicitly installed and not required as dependencies: pacman -Qet To list a dependency tree of a package: pactree package name To list all the packages recursively depending on an installed package, use whoneeds from ccr/pkgtools 4: whoneeds package name or the reverse flag to pactree: pactree -r package name The pacman databases are normally located at /var/lib/pacman/sync. For each repository specified in /etc/pacman.conf there will be a corresponding database file located there. Database files are xzipped tarball archives containing one directory for each package, for example for the core/which package: tree which-2.20-6 which-2.20-6 |-- depends -- desc The depends file lists the packages this package depends on, while desc has a description of the package such as the file size and the MD5 hash. pacman stores its downloaded packages in /var/cache/pacman/pkg/ and does not remove the old or uninstalled versions automatically, therefore it is necessary to deliberately clean up that folder periodically to prevent such folder to grow indefinitely in size. The built-in option to remove all the cached packages that are not currently installed is: pacman -Sc Only do this when certain that previous package versions are not required, for example for a later downgrade. pacman -Sc only leaves the versions of packages which are currently installed available, older versions would have to be retrieved through other means. It is possible to empty the cache folder fully with pacman -Scc. In addition to the above, this also prevents from reinstalling a package directly from the cache folder in case of need, thus requiring a new download. It should be avoided unless there is an immediate need for disk space. Because of the above limitations, consider an alternative for more control over which packages, and how many, are deleted from the cache: The paccache script, provided by the core/pacman package itself, deletes all cached versions of each package regardless of whether they’re installed or not, except for the most recent 3, by default: paccache -r Note that you can create hooks to run this automatically after every pacman transaction. You can also define how many recent versions you want to keep: paccache -rk 1 To remove all cached versions of uninstalled packages, re-run paccache with: paccache -ruk0 See paccache -h for more options. Download a package without installing it: pacman -Sw package name Install a local package that is not from a remote repository e.g. the package is built from a source tarball in the CCR 7 : pacman -U /path/to/package/package name-version.pkg.tar.xz To keep a copy of the local package in pacman’s cache, use: pacman -U file:///path/to/package/package name-version.pkg.tar.xz Install a remote package not from a repository stated in pacman’s configuration files : pacman -U http://www.example.com/repo/example.pkg.tar.xz To inhibit the -S, -U and -R actions, -p can be used. pacman always lists packages to be installed or removed and asks for permission before it takes action. The pacman database distinguishes the installed packages in two groups according to the reason why they were installed: explicitly-installed are the packages that were literally passed to a generic pacman -S or -U command; dependencies are the packages that, despite never in general having been passed to a pacman installation command, were implicitly installed as a dependency of another package that was explicitly installed. When installing a package, it is possible to force its installation reason to dependency with: pacman -S --asdeps package name When re installing a package, though, the current installation reason is preserved by default. The list of explicitly-installed packages can be shown with pacman -Qe, while the complementary list of dependencies can be shown with pacman -Qd. To change the installation reason of an already installed package, execute: pacman -D --asdeps package name Use --asexplicit to do the opposite operation. Note that installing optional dependencies with --asdeps will cause it such that if you remove orphan packages, pacman will also remove leftover optional dependencies. Sync the files database you can set a cron job or a systemd timer to sync the files database regularly : pacman -Fy Search for a package containing a file, e.g.: pacman -Fs pacman core/pacman 5.0.1-4 usr/bin/pacman usr/share/bash-completion/completions/pacman extra/xscreensaver 5.36-1 usr/lib/xscreensaver/pacman For advanced functionality install ccr/pkgfile 10, which uses a separate database with all files and their associated packages. pacman’s settings are located in /etc/pacman.conf: this is the place where the user configures the program to work in the desired manner. In-depth information about the configuration file can be found in man 5 pacman.conf. General options are in the options section. Read man 8 pacman or look in the default pacman.conf for information on what can be done here. To see old and new versions of available packages, uncomment the VerbosePkgLists line in /etc/pacman.conf. The output of pacman -Syu will be like this: Package 6 Old Version New Version Net Change Download Size extra/libmariadbclient 10.1.9-4 10.1.10-1 0.03 MiB 4.35 MiB extra/libpng 1.6.19-1 1.6.20-1 0.00 MiB 0.23 MiB extra/mariadb 10.1.9-4 10.1.10-1 0.26 MiB 13.80 MiB ⚠️ Partial upgrades are not supported 69 To have a specific package skipped when upgrading the system, specify it as such: IgnorePkg=linux For multiple packages use a space-separated list, or use additional IgnorePkg lines. Also, glob patterns can be used. If you want to skip packages just once, you can also use the --ignore option on the command-line - this time with a comma-separated list. It will still be possible to upgrade the ignored packages using pacman -S; in this case pacman will remind you that the packages have been included in an IgnorePkg statement. ⚠️ Partial upgrades are not supported 69 As with packages, skipping a whole package group is also possible: IgnoreGroup=plasma To always skip installation of specific directories list them under NoExtract. For example, to avoid installation of systemd units use this: NoExtract=usr/lib/systemd/system/ Later rules override previous ones, and you can negate a rule by prepending . Note that pacman issues warning messages about missing locales when updating a package for which locales have been cleared by localepurge or bleachbit. Commenting the CheckSpace option in pacman.conf suppresses such warnings, but consider that the space-checking functionality will be disabled for all packages. If you have several configuration files e.g. a primary configuration, and another configuration with testing repository enabled and would have to share options between configurations yo