GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing wiki.archlinux.org — pacman - ArchWiki
Related articles 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 Arch 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 bsdtar(1) tar format for packaging. Tip The pacman package contains tools such as makepkg and vercmp(8). Other useful tools such as pactree and checkupdates are found in pacman-contrib. Run
pacman -Ql pacman pacman-contrib | grep -E 'bin/.+' to see the full list.UsageWhat follows is just a small sample of the operations that pacman can perform. To read more examples, refer to pacman(8). Tip For those who have used other Linux distributions before, there is a helpful Pacman/Rosetta article.
Installing packagesA 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:
Note
Warning When installing packages in Arch, avoid refreshing the package list without upgrading the system (for example, when a package is no longer found in the official repositories). In practice, do not run
pacman -Sy package_name instead of pacman -Syu package_name, as the former could lead to dependency issues. See System maintenance#Partial upgrades are unsupported and BBS#89328.Installing specific packagesTo install a single package or list of packages, including dependencies, issue the following command: # pacman -S package_name1 package_name2 ... Tip The same command can be used to reinstall a package.
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 extra-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}
Virtual packagesA 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 installed a package providing the virtual package. An example is the dbus-units package. Tip When there are multiple candidates, the list of choices presented will sort first by repositories in the order they appear in
pacman.conf, then alphabetically when multiple results exist from the same repository.Installing package groupsSome 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 gnome 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://archlinux.org/groups/ to see what package groups are available. Note 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.Removing packagesTo 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 Warning When removing a group, such as gnome, this ignores the install reason of the packages in the group, because it acts as though each package in the group is listed separately. Install reason of dependencies is still respected.
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 Warning The operation above is recursive, and must be used with care since it can remove many potentially needed packages.
To remove a package, which is required by another package, without removing the dependent package: # pacman -Rdd package_name Warning The operation above can break a system and should be avoided. See System maintenance#Avoid certain pacman commands.
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 # pacman -Rn package_name Note Pacman will not remove configurations that the application itself creates (for example "dotfiles" in the home directory).
Upgrading packagesWarning
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 Querying package databasespacman queries the local package database with the Note Sync the files database before querying it to get up-to-date results:
# pacman -Fy Tip You can enable/start the
pacman-filesdb-refresh.timer (provided within the pacman-contrib package) to refresh pacman files database weekly.pacman can search for packages in the database, searching both in packages' names and descriptions: $ pacman -Ss string1 string2 ... Sometimes, $ 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 (e.g. its dependencies): $ pacman -Si package_name For locally installed packages: $ pacman -Qi package_name Passing two $ 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 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 To list all packages explicitly installed and not required as dependencies: $ pacman -Qet See pacman/Tips and tricks for more examples. For advanced functionality, install pkgfile, which uses a separate database with all files and their associated packages. PactreeInstall the pacman-contrib package to get pactree(8). To view the dependency tree of a package: $ pactree package_name To view the dependent tree of a package, pass the reverse flag Database structureThe pacman databases are normally located at $ tree which-2.21-5 which-2.21-5 |-- desc The Cleaning the package cachePacman stores its downloaded packages in
However, it is necessary to deliberately clean up the cache periodically to prevent the directory from growing indefinitely in size. The paccache(8) script, provided within the pacman-contrib package, deletes all cached versions of installed and uninstalled packages, except for the most recent three, by default: # paccache -r Enable and start Tip You can create a hook to run this automatically after every pacman transaction, install paccache-hookAUR or see other examples
You can also define how many recent versions you want to keep. To retain only one past version use: # paccache -rk1 Add the # paccache -ruk0 See 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 To remove all the cached packages that are not currently installed, and the unused sync databases, 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 directory: # pacman -Scc Warning One should avoid deleting from the cache all past versions of installed packages and all uninstalled packages unless one desperately needs to free some disk space. This will prevent downgrading or reinstalling packages without downloading them again.
pkgcachecleanAUR and pacleanerAUR are two further alternatives to clean the cache. Additional commandsDownload 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.zst To keep a copy of the local package in pacman's cache, use: # pacman -U file:///path/to/package/package_name-version.pkg.tar.zst Install a 'remote' package (not from a repository stated in pacman's configuration files): # pacman -U http://www.example.com/repo/example.pkg.tar.zst Dry runpacman always lists packages to be installed or removed, and asks for permission before taking any action. To get a list in a processable format, and to prevent the actions of
Installation reasonThe pacman database organizes installed packages into two groups, according to installation reason:
When installing a package, it is possible to force its installation reason to dependency with: # pacman -S --asdeps package_name The command is normally used because explicitly-installed packages may offer optional packages, usually for non-essential features for which the user has discretion. Tip Installing optional dependencies with
--asdeps will ensure that, if you remove orphans, pacman will also remove optional packages set this way.When reinstalling a package, though, the current installation reason is preserved by default. The list of explicitly-installed packages can be shown with To change the installation reason of an already installed package, execute: # pacman -D --asdeps package_name Use Note Using
--asdeps and --asexplicit options when upgrading, such as with pacman -Syu --asdeps package_name, is discouraged. This would change the installation reason of not only the package being installed, but also the packages being upgraded.What happens during package install/upgrade/removalWhen successful, the workflow of a transaction follows five high-level steps plus pre/post transaction hooks:
Configurationpacman settings are located in General optionsGeneral options are in the Comparing versions before updatingTo see old and new versions of available packages, uncomment the "VerbosePkgLists" line in 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 Parallel downloadsThe number of packages being downloaded in parallel (at the same time) are configured in Skip package from being upgradedWarning Be careful in skipping packages, since partial upgrades are unsupported.
To have a specific package skipped when upgrading the system, add this line in the IgnorePkg=linux For multiple packages use a space-separated list, or use additional It will still be possible to upgrade the ignored packages using Skip package group from being upgradedWarning Be careful in skipping package groups, since partial upgrades are unsupported.
As with packages, skipping a whole package group is also possible: IgnoreGroup=gnome Skip file from being upgradedAll files listed with a NoUpgrade=path/to/file Multiple files can be specified like this: NoUpgrade=path/to/file1 path/to/file2 Note The path refers to files in the package archive. Therefore, do not include the leading slash.
Skip files from being installed to systemTo always skip installation of specific files or directories list them under NoExtract=usr/share/bash-completion/completions/* Later rules override previous ones, and you can negate a rule by prepending Maintain several configuration filesIf 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 Include = /path/to/common/settings where Hookspacman can run pre- and post-transaction hooks from the pacman hooks are used, for example, in combination with For more information on alpm hooks, see alpm-hooks(5). Repositories and mirrorsBesides the special [options] section, each other 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 Package cache directorypacman stores downloaded package files in cache, in a directory denoted by Cache directory may grow over time, even if keeping just the freshest versions of installed packages. If you want to move that directory to some more convenient place, do one of the following:
Warning Do not symlink the
/var/cache/pacman/pkg/ directory to some other location. It will cause pacman to misbehave, especially when pacman attempts to update itself.Package securitypacman supports package signatures, which add an extra layer of security to the packages. The default configuration, Troubleshooting"Failed to commit transaction (conflicting files)" errorIf you see the following error: [1] 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 (although to be sure, you should try to find out how these files got there in the first place). A safe way is to first check if another package owns the file ( If you had installed a program manually without using pacman, for example through Every installed package provides a Warning Generally avoid using the
--overwrite switch. See System maintenance#Avoid certain pacman commands."Failed to commit transaction (invalid or corrupted package)" errorLook for .part files (partially downloaded packages) in # find /var/cache/pacman/pkg/ -iname "*.part" -delete That same error may also appear if archlinux-keyring is out-of-date, preventing pacman from verifying signatures. See Pacman/Package signing#Upgrade system regularly for the fix and how to avoid it in the future. "Failed to init transaction (unable to lock database)" errorWhen pacman is about to alter the package database, for example installing a package, it creates a lock file at 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 Tip You can run
fuser /var/lib/pacman/db.lck as root to verify if there is any process still using it.Packages cannot be retrieved on installationThis error manifests as Firstly, ensure the package actually exists. If certain the package exists, your package list may be out-of-date. Try running If pacman reports there is nothing to update, but the 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 FAQ#Why is there only a single version of each shared library in the official repositories?. Fixing an unbootable system caused by an interrupted upgradeWhether due to power loss, kernel panic or hardware failure an update may be interrupted. In most cases, there will not be much damage but the system will likely be unbootable.
# pacman -Syu $(grep "\[2025-07-27T22.*\] \[ALPM\] upgraded" /var/log/pacman.log | cut -d " " -f4 | tr "\n" " ") Replicating the exact upgrade is needed to ensure the right scriptlets and hooks will run. pacman crashes during an upgradeIn the case that pacman crashes with a "database write" error while removing packages, and reinstalling or upgrading packages fails thereafter, do the following:
pacman: command not foundIf Never symlink If you have already encountered this problem and broke your system, you can manually extract Manually reinstalling pacmanUsing pacman-staticpacman-staticAUR is a statically compiled version of pacman, so it will be able to run even when the libraries on the system are not working. This can also come in handy when a partial upgrade was performed and pacman can not run anymore. Using a precompiled pacman-static binary when PKGBUILD build failsIn some situations, your system may be too broken to run makepkg or to build the pacman-staticAUR package (e.g., due to missing or incompatible libraries). In this case, you can download a precompiled pacman-static binary from a trusted source. This static binary does not depend on system libraries and can be used to restore a working pacman on your system. An outdated binary is provided by https://pkgbuild.com/~morganamilo/pacman-static/x86_64/bin/pacman-static Download it, make it executable, then: # ./pacman-static -Syu pacman This will update your system and reinstall pacman, fixing broken dependencies related to missing shared libraries. Using an external pacmanIf even pacman-static does not work, it is possible to recover using an external pacman. One of the easiest methods to do so is by using the archiso and simply using By manually extractingWarning It is extremely easy to break your system even worse using this approach. Use this only as a last resort if the method from #pacman crashes during an upgrade is not an option.
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:
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.zst -C / --exclude .PKGINFO --exclude .INSTALL --exclude .MTREE --exclude .BUILDINFO Note the use of the "Unable to find root device" error after rebootingMost likely the initramfs became corrupted during a kernel update (improper use of pacman's Tip In case you removed the Fallback entry, you can always press the
Tab key when the boot loader menu shows up (for Syslinux) or e (for GRUB or systemd-boot), rename it initramfs-linux-fallback.img and press Enter or b (depending on your boot loader) to boot with the new parameters.Once the system starts, run this command (for the stock linux 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 to # arch-chroot -S /mnt # pacman -Syu mkinitcpio systemd linux Note
Reinstalling the kernel (the linux package) will automatically re-generate the initramfs image with Afterwards, it is recommended that you run "Warning: current locale is invalid; using default "C" locale" errorAs the error message says, your locale is not correctly configured. See Locale. Missing locales warning messagesWhen locale files are intentionally removed by tools such as bleachbit or localepurgeAUR, To suppress these warnings, you can comment out the pacman does not honor proxy settingsMake sure that the relevant environment variables ( How do I reinstall all packages, retaining information on whether something was explicitly installed or as a dependency?To reinstall all the native packages: You will then need to reinstall all the foreign packages, which can be listed with "Cannot open shared object file" errorIt 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 ( Now you need to reinstall the broken package. Note that you need to use That is it. Update the rest of the system. Freeze of package downloadsSome issues have been reported regarding network problems that prevent pacman from updating/synchronizing repositories. [2] [3] 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. Failed retrieving file 'core.db' from mirrorIf you receive this error message with correct mirrors, try setting a different name server. error: 'local-package.pkg.tar': permission deniedIf you want to install a package on an sshfs mount using error: could not determine cachedir mount point /var/cache/pacman/pkgUpon executing, e.g., error: could not determine cachedir mount point /var/cache/pacman/pkg error: failed to commit transaction (not enough free disk space) This is frequently caused by the chroot directory not being a mountpoint when the chroot is entered. See the note at Install Arch Linux from existing Linux#Downloading basic tools for a solution, and arch-chroot(8) for an explanation and an example of using bind mounting to make the chroot directory a mountpoint. error: GPGME error: No dataIf you are unable to update packages and receive this error, then try If removing sync files does not help, check that the sync files are If sync files are of the correct type, there might be an issue with the mirror server. Look up the mirror server(s) in use with error: GPGME error: General error and ":: File /var/cache/pacman/pkg/<package>.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).If this error occurs and you are, for instance, unable to update your system or any package at all, it is possible that you have In this case, Reinstall broken or out-of-sync packagesOne may use the # LC_ALL=C.UTF-8 pacman -Qk 2>/dev/null | grep -v ' 0 missing files' | cut -d: -f1 |
while read -r package; do
pacman -S "$package" --noconfirm
done
Suppose that your local database located in Check for missing/corrupted filesIn case of accidental deletion of system files or other file anomalies, run this command to see which files are missing from all pacman packages: # pacman -Qk $(pacman -Qsq) | grep -v " 0 missing files" It will print nothing if nothing is missing, and something like this if something is missing: [package]: X total files, [>=1] missing file(s) To check for file corruption as well: # pacman -Qkk $(pacman -Qsq) | grep -v " 0 altered files" There will be false positives, especially in /etc/* See alsoRetrieved from "https://wiki.archlinux.org/index.php?title=Pacman&oldid=888786" |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |