Return to Linux package managers, Arch Linux, Manjaro Linux or Package managers
The pacman package manager is one of the major distinguishing features of Arch Linux. It combines a simple binary package format with an easy-to-use build system. The goal of pacman is to make it possible to easily manage packages, whether they are from the official repositories or the user's own builds.
Pacman keeps the system up to date by synchronizing package lists with the master server. This server/client model also allows the user to download/install packages with a simple command, complete with all required dependencies.
Pacman is written in the C programming language and uses the (https://jlk.fjfi.cvut.cz/arch/manpages/man/bsdtar.1) tar format for packaging.
package contains tools such as makepkg and
. Other useful tools such as pactree and checkupdates are found in
(formerly part of pacman). Run
grep -E 'bin/.+'}} to see the full list.}}
What follows is just a small sample of the operations that pacman can perform. To read more examples, refer to
.
A package is an archive containing:
Arch's package manager pacman can install, update, and remove those packages. Using packages instead of compiling and installing programs yourself has various benefits:
. Use the Querying package databases command to view the optional dependencies of a package.
option. For details see the Installation reason section.}}
instead of
, as this could lead to dependency issues. See Partial upgrades are unsupported and BBS#89328.}}
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 (see this forum thread):
# pacman -S $(pacman -Ssq ''package_regex'')
Sometimes there are multiple versions of a package in different repositories (e.g. extra and testing). To install the version from the extra repository in this example, the repository needs to be defined in front of the package name:
# pacman -S extra/''package_name''
To install a number of packages sharing similar patterns in their names one can use curly brace expansion. For example:
# pacman -S plasma-{desktop,mediacenter,nm}
This can be expanded to however many levels needed:
# pacman -S plasma-{workspace{,-wallpapers},pa}
A virtual package is a special package which does not exist by itself, but is provided by one or more other packages. Virtual packages allow other packages to not name a specific package as a dependency, in case there are several candidates. Virtual packages cannot be installed by their name, instead they become installed in your system when you have install a package providing the virtual package.
Some packages belong to a group of packages that can all be installed simultaneously. For example, issuing the command:
# pacman -S gnome
will prompt you to select the packages from the
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 gnome group, run:
# pacman -Sg gnome
Also visit https://www.archlinux.org/groups/ to see what package groups are available.
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''
The above may sometimes refuse to run when removing a group which contains otherwise needed packages. In this case try:
# pacman -Rsu ''package_name''
To remove a package, its dependencies and all the packages that depend on the target package:
# 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
option:
# pacman -Rn ''package_name''
Pacman can update all packages on the system with just one command. This could take quite 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
flag, the sync database with the
flag and the files database with the
flag. See
,
and
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 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 -F ''string1'' ''string2'' ...
To display extensive information about a given package:
$ pacman -Si ''package_name''
For locally installed packages:
$ pacman -Qi ''package_name''
Passing two
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
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 -F ''/path/to/file_name''
To list all packages no longer required as dependencies (orphans):
$ pacman -Qdt
in your hook:
}}
To list all packages explicitly installed and not required as dependencies:
$ pacman -Qet
See Pacman/Tips and tricks for more examples.
is not part of the
package anymore. Instead it can be found in
.}}
To view the dependency tree of a package:
$ pactree ''package_name''
To view the dependant tree of a package, pass the reverse flag
to pactree, or use whoneeds from
.
The pacman databases are normally located at
. For each repository specified in
there will be a corresponding database file located there. Database files are gzipped tar archives containing one directory for each package, for example for the
package:
– desc }}
The
file contains meta data such as the package description, dependencies, file size and MD5 hash.
Pacman stores its downloaded packages in
and does not remove the old or uninstalled versions automatically. This has some advantages:
However, it is necessary to deliberately clean up the cache periodically to prevent the folder to grow indefinitely in size.
The
script, provided within the
package, deletes all cached versions of installed and uninstalled packages, except for the most recent 3, by default:
# paccache -r
to discard unused packages weekly.
.}}
You can also define how many recent versions you want to keep. To retain only one past version use:
# paccache -rk1
Add the
/
switch to limit the action of paccache to uninstalled packages. For example to remove all cached versions of uninstalled packages, use the following:
# paccache -ruk0
See
for more options.
Pacman also has some built-in options to clean the cache and the leftover database files from repositories which are no longer listed in the configuration file
. However pacman does not offer the possibility to keep a number of past versions and is therefore more aggressive than paccache default options.
To remove all the cached packages that are not currently installed, and the unused sync database, execute:
# pacman -Sc
To remove all files from the cache, use the clean switch twice, this is the most aggressive approach and will leave nothing in the cache folder:
# pacman -Scc
and
are two further alternatives to clean the cache.
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 from the AUR):
# pacman -U ''/path/to/package/package_name-version.pkg.tar.xz''
To keep a copy of the local package in pacmans cache, use:
# pacman -U file:///''path/to/package/package_name-version.pkg.tar.xz''
Install a 'remote' package (not from a repository stated in pacmans configuration files):
# pacman -U ''http://www.example.com/repo/example.pkg.tar.xz ''
To inhibit the
,
and
actions,
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:
or
command;
When installing a package, it is possible to force its installation reason to dependency with:
# pacman -S --asdeps ''package_name''
will cause it such that if you remove orphans, pacman will also remove leftover optional dependencies.}}
When reinstalling a package, though, the current installation reason is preserved by default.
The list of explicitly-installed packages can be shown with
, while the complementary list of dependencies can be shown with
.
To change the installation reason of an already installed package, execute:
# pacman -D --asdeps ''package_name''
Use
to do the opposite operation.
and
options when upgrading, such as with
, is discouraged. This would change the installation reason of not only the package being installed, but also the packages being upgraded.}}
Sync the files database:
# pacman -Fy
Search for a package containing a file, e.g.:
For advanced functionality install pkgfile, which uses a separate database with all files and their associated packages.
Pacmans settings are located in
: 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
.
General options are in the
section. Read
or look in the default
for information on what can be done here.
To see old and new versions of available packages, uncomment the “VerbosePkgLists” line in
. The output of
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
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
lines. Also, glob patterns can be used. If you want to skip packages just once, you can also use the
option on the command-line - this time with a comma-separated list.
It will still be possible to upgrade the ignored packages using
: in this case pacman will remind you that the packages have been included in an
statement.
As with packages, skipping a whole package group is also possible:
IgnoreGroup=gnome
All files listed with a
directive will never be touched during a package install/upgrade, and the new files will be installed with a .pacnew extension.
NoUpgrade=''path/to/file''
To always skip installation of specific directories list them under
. 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
.
option in
suppresses such warnings, but consider that the space-checking functionality will be disabled for all packages.}}
If you have several configuration files (e.g. main configuration and configuration with testing repository enabled) and would have to share options between configurations you may use
option declared in the configuration files, e.g.:
Include = ''/path/to/common/settings''
where
file contains the same options for both configurations.
Pacman can run pre- and post-transaction hooks from the
directory; more directories can be specified with the
option in
, which defaults to
. Hook file names must be suffixed with .hook. Pacman hooks are not interactive.
Pacman hooks are used, for example, in combination with
and
to automatically create system users and files during the installation of packages. For example, package
specifies that it wants a system user called
See also:
and certain directories owned by this user. The pacman hooks
and
invoke
and
when pacman determines that package
contains files specifying users and tmp files.
For more information on alpm hooks, see
.
Besides the special [options] section, each other
in
defines a package repository to be used. A repository is a logical collection of packages, which are physically stored on one or more servers: for this reason each server is called a mirror for the repository.
Repositories are distinguished between official and unofficial. The order of repositories in the configuration file matters; repositories listed first will take precedence over those listed later in the file when packages in two repositories have identical names, regardless of version number. In order to use a repository after adding it, you will need to upgrade the whole system first.
Each repository section allows defining the list of its mirrors directly or in a dedicated external file through the
directive: for example, the mirrors for the official repositories are included from
. See the Mirrors article for mirror configuration.
Pacman supports package signatures, which add an extra layer of security to the packages. The default configuration,
, enables signature verification for all the packages on a global level: this can be overridden by per-repository
lines. For more details on package signing and signature verification, take a look at pacman-key.
If you see the following error: s://bbs.archlinux.org/viewtopic.php?id=56373
error: could not prepare transaction error: failed to commit transaction (conflicting files) ''package'': ''/path/to/file'' exists in filesystem Errors occurred, no packages were upgraded.
This is happening because pacman has detected a file conflict, and by design, will not overwrite files for you. This is by design, not a flaw.
The problem is usually trivial to solve. A safe way is to first check if another package owns the file (
). If the file is owned by another package, file a bug report. If the file is not owned by another package, rename the file which 'exists in filesystem' and re-issue the update command. If all goes well, the file may then be removed.
If you had installed a program manually without using pacman, for example through
, you have to remove/uninstall this program with all of its files. See also Identify files not owned by any package.
Every installed package provides a
file that contains metadata about this package. If this file gets corrupted, is empty or goes missing, it results in
errors when trying to update the package. Such an error usually concerns only one package. Instead of manually renaming and later removing all the files that belong to the package in question, you may explicitly run
to force pacman to overwrite files that match
.
switch. See Avoid certain pacman commands.}}
Look for .part files (partially downloaded packages) in
and remove them (often caused by usage of a custom
in
).
# find /var/cache/pacman/pkg/ -iname "*.part" -delete
When pacman is about to alter the package database, for example installing a package, it creates a lock file at
. This prevents another instance of pacman from trying to alter the package database at the same time.
If pacman is interrupted while changing the database, this stale lock file can remain. If you are certain that no instances of pacman are running then delete the lock file:
# rm /var/lib/pacman/db.lck
This error manifests as
,
or
.
Firstly, ensure the package actually exists. If certain the package exists, your package list may be out-of-date. Try running
to force a refresh of all package lists and upgrade. Also make sure the selected mirrors are up-to-date and repositories are correctly configured.
It could also be that the repository containing the package is not enabled on your system, e.g. the package could be in the multilib repository, but multilib is not enabled in your
.
See also Why is there only a single version of each shared library in the official repositories.
In the case that pacman crashes with a “database write” error while removing packages, and reinstalling or upgrading packages fails thereafter, do the following:
as root, and check the mount has sufficient space with
as root.
.
Even if pacman is terribly broken, you can fix it manually by downloading the latest packages and extracting them to the correct locations. The rough steps to perform are:
dependencies to install
to update the package database accordingly
If you have a healthy Arch system on hand, you can see the full list of dependencies with:
$ pacman -Q $(pactree -u pacman)
But you may only need to update a few of them depending on your issue. An example of extracting a package is
# tar -xvpwf ''package.tar.xz'' -C / --exclude .PKGINFO --exclude .INSTALL --exclude .MTREE --exclude .BUILDINFO
Note the use of the
flag for interactive mode. Running non-interactively is very risky since you might end up overwriting an important file. Also take care to extract packages in the correct order (i.e. dependencies first). This forum post contains an example of this process where only a couple pacman dependencies are broken.
Most likely the initramfs became corrupted during a kernel update (improper use of pacmans
option can be a cause). There are two options; first, try the Fallback entry.
key when the boot loader menu shows up (for Syslinux) or
(for GRUB or systemd-boot), rename it
and press
or
(depending on your boot loader) to boot with the new parameters.}}
Once the system starts, run this command (for the stock
kernel) either from the console or from a terminal to rebuild the initramfs image:
# mkinitcpio -p linux
If that does not work, from a current Arch release (CD/DVD or USB stick), mount your root and boot partitions. Then chroot using arch-chroot:
# arch-chroot /mnt # pacman -Syu mkinitcpio systemd linux
script.
, please check your internet connection.
to use pacman on your root partition.}}
Reinstalling the kernel (the
package) will automatically re-generate the initramfs image with
. There is no need to do this separately.
Afterwards, it is recommended that you run
,
and
.
Potential solutions:
package first, i.e.
If installing Arch with an outdated ISO, you are likely prompted to import PGP keys. Agree to download the key to proceed. If you are unable to add the PGP key successfully, update the keyring or upgrade
(see above).
If packages are signed with new keys, which were only recently added to
, these keys are not locally available during update (chicken-egg-problem). The installed
does not contain the key, until it is updated. Pacman tries to bypass this by a lookup through a key-server, which might not be possible e.g. behind proxys or firewalls and results in the stated error. Upgrade
first as shown above.
When the system time is faulty, signing keys are considered expired (or invalid) and signature checks on packages will fail with the following error:
error: ''package'': signature from "User" is invalid error: failed to commit transaction (invalid or corrupted package (PGP signature)) Errors occured, no packages were upgraded.
Make sure to correct the system time, for example with
run as root, and run
as root before subsequent installations or upgrades.
As the error message says, your locale is not correctly configured. See Locale.
Make sure that the relevant environment variables (
,
etc.) are set up. If you use pacman with sudo, you need to configure sudo to pass these environment variables to pacman. Also, ensure the configuration of dirmngr has
in
to honor the proxy when refreshing the keys.
To reinstall all the native packages:
pacman -S -}} or
(the
option preserves the installation reason by default).
You will then need to reinstall all the foreign packages, which can be listed with
.
It looks like previous pacman transaction removed or corrupted shared libraries needed for pacman itself.
To recover from this situation you need to unpack required libraries to your filesystem manually. First find what package contains the missed library and then locate it in the pacman cache (
). Unpack required shared library to the filesystem. This will allow to run pacman.
Now you need to reinstall the broken package. Note that you need to use
flag as you just unpacked system files and pacman does not know about it. Pacman will correctly replace our shared library file with one from package.
That's it. Update the rest of the system.
Some issues have been reported regarding network problems that prevent pacman from updating/synchronizing repositories. s://bbs.archlinux.org/viewtopic.php?id=68944 s://bbs.archlinux.org/viewtopic.php?id=65728 When installing Arch Linux natively, these issues have been resolved by replacing the default pacman file downloader with an alternative (see Improve pacman performance for more details). When installing Arch Linux as a guest OS in VirtualBox, this issue has also been addressed by using Host interface instead of NAT in the machine properties.
If you receive this error message with correct mirrors, try setting a different name server.
If you want to install a package on an sshfs mount using
and receive this error, move the package to a local directory and try to install again.
When successfully completing a package transaction, pacman performs the following high-level steps:
hooks apply, they are executed.
function is executed (or
or
in the case of an upgraded or removed package).
function is executed (or
or
in the case of an upgraded or removed package).
hooks that exist at the end of the transaction apply, they are executed.