Difference between revisions of "Pacman"

From ArchWiki
Jump to: navigation, search
m (Installing package groups)
m (a small title clean-up)
(14 intermediate revisions by 4 users not shown)
Line 23: Line 23:
 
[[zh-TW:Pacman]]
 
[[zh-TW:Pacman]]
 
{{Lowercase title}}
 
{{Lowercase title}}
 
 
{{Article summary start}}
 
{{Article summary start}}
 
{{Article summary text|Pacman is the Arch Linux [[Wikipedia:Package management system|package manager]]. Package managers are used to install, upgrade, and remove software. This article covers basic usage and troubleshooting tips.}}
 
{{Article summary text|Pacman is the Arch Linux [[Wikipedia:Package management system|package manager]]. Package managers are used to install, upgrade, and remove software. This article covers basic usage and troubleshooting tips.}}
Line 45: Line 44:
 
{{Article summary end}}
 
{{Article summary end}}
  
The '''[https://archlinux.org/pacman/ pacman]''' [[Wikipedia:Package management system|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|build system]]. The goal of pacman is to make it possible to easily manage packages, whether they are from the [[Official Repositories|official Arch repositories]] or the user's own builds.
+
The '''[https://www.archlinux.org/pacman/ pacman]''' [[Wikipedia:Package management system|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|build system]]. The goal of pacman is to make it possible to easily manage packages, whether they are from the [[Official Repositories|official Arch 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 you to download/install packages with a simple command, complete with all required dependencies.
 
Pacman keeps the system up to date by synchronizing package lists with the master server. This server/client model also allows you to download/install packages with a simple command, complete with all required dependencies.
Line 65: Line 64:
 
To skip upgrading a specific package, specify it as such:
 
To skip upgrading a specific package, specify it as such:
  
{{bc|<nowiki>IgnorePkg=linux</nowiki>}}
+
IgnorePkg=linux
  
 
For multiple packages use a space-separated list, or use additional {{ic|IgnorePkg}} lines.
 
For multiple packages use a space-separated list, or use additional {{ic|IgnorePkg}} lines.
Line 73: Line 72:
 
As with packages, skipping a whole package group is also possible:
 
As with packages, skipping a whole package group is also possible:
  
{{bc|<nowiki>IgnoreGroup=gnome</nowiki>}}
+
IgnoreGroup=gnome
  
 
==== Skip files from being installed to system ====
 
==== Skip files from being installed to system ====
Line 79: Line 78:
 
To always skip installation of specific directories list them under {{Ic|NoExtract}}. For example, to avoid installation of [[systemd]] units use this:
 
To always skip installation of specific directories list them under {{Ic|NoExtract}}. For example, to avoid installation of [[systemd]] units use this:
  
{{bc|<nowiki>NoExtract=usr/lib/systemd/system/*</nowiki>}}
+
NoExtract=usr/lib/systemd/system/*
  
 
=== Repositories ===
 
=== Repositories ===
  
This section defines which repositories to use, as referred to in {{ic|/etc/pacman.conf}}. They can be stated here directly or included from another file.
+
This section defines which [[Official Repositories|repositories]] to use, as referred to in {{ic|/etc/pacman.conf}}. They can be stated here directly or included from another file (such as {{ic|/etc/pacman.d/mirrorlist}}), thus making it necessary to maintain only one list.
  
All official repositories use the same {{ic|/etc/pacman.d/mirrorlist}} file which uses the {{ic|$repo}} variable, making it necessary to maintain only one list.
+
{{hc|/etc/pacman.conf|2=
 
+
The following is an example for the [[Official Repositories|official repositories]] that defers [[mirrors]] to {{ic|/etc/pacman.d/mirrorlist}}.
+
 
+
{{bc|<nowiki>
+
 
#[testing]
 
#[testing]
 
#SigLevel = PackageRequired
 
#SigLevel = PackageRequired
Line 125: Line 120:
 
#[custom]
 
#[custom]
 
#SigLevel = Optional TrustAll
 
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs
+
#Server = file:///home/custompkgs}}
</nowiki>}}
+
  
 
{{Warning|Care should be taken when using the [testing] repository. It is in active development and updating may cause some packages to stop working. People who use the [testing] repository are encouraged to subscribe to the [https://mailman.archlinux.org/mailman/listinfo/arch-dev-public arch-dev-public mailing list] for current information.}}
 
{{Warning|Care should be taken when using the [testing] repository. It is in active development and updating may cause some packages to stop working. People who use the [testing] repository are encouraged to subscribe to the [https://mailman.archlinux.org/mailman/listinfo/arch-dev-public arch-dev-public mailing list] for current information.}}
Line 138: Line 132:
 
What follows is just a small sample of the operations that pacman can perform. To read more examples, refer to [https://www.archlinux.org/pacman/pacman.8.html man pacman].
 
What follows is just a small sample of the operations that pacman can perform. To read more examples, refer to [https://www.archlinux.org/pacman/pacman.8.html man pacman].
  
===Installing packages===
+
=== Installing packages ===
 +
 
 +
==== Installing specific packages ====
  
====Installing specific packages====
 
 
To install a single package or list of packages (including dependencies), issue the following command:
 
To install a single package or list of packages (including dependencies), issue the following command:
  
Line 149: Line 144:
 
  # pacman -S extra/''package_name''
 
  # pacman -S extra/''package_name''
  
====Installing package groups====
+
==== Installing package groups ====
 +
 
 
Some packages belong to a group of packages that can all be installed simultaneously. For example, issuing the command:
 
Some packages belong to a group of packages that can all be installed simultaneously. For example, issuing the command:
  
Line 190: Line 186:
 
{{Note|Pacman will not remove configurations that the application itself creates (for example "dotfiles" in the home folder).}}
 
{{Note|Pacman will not remove configurations that the application itself creates (for example "dotfiles" in the home folder).}}
  
===Upgrading packages===
+
=== Upgrading packages ===
  
 
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. This command can synchronize the repository databases ''and'' update the system's packages (excluding 'local' packages that are not in the configured repositories):
 
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. This command can synchronize the repository databases ''and'' update the system's packages (excluding 'local' packages that are not in the configured repositories):
Line 202: Line 198:
 
{{Tip|Remember that pacman's output is logged in {{ic|/var/log/pacman.log}}.}}
 
{{Tip|Remember that pacman's output is logged in {{ic|/var/log/pacman.log}}.}}
  
Before upgrading, it is advisable to visit the [https://archlinux.org/ Arch Linux home page] to check the latest news (or subscribe to the RSS feed): when updates require out-of-the-ordinary user intervention (more than what can be handled simply by following the instructions given by pacman), an appropriate news post will be made.
+
Before upgrading, it is advisable to visit the [https://www.archlinux.org/ Arch Linux home page] to check the latest news (or subscribe to the RSS feed): when updates require out-of-the-ordinary user intervention (more than what can be handled simply by following the instructions given by pacman), an appropriate news post will be made.
  
 
If one encounters problems that cannot be solved by these instructions, make sure to search the forum. It is likely that others have encountered the same problem and have posted instructions for solving it.
 
If one encounters problems that cannot be solved by these instructions, make sure to search the forum. It is likely that others have encountered the same problem and have posted instructions for solving it.
Line 244: Line 240:
 
One can also query the database to know which package a file in the file system belongs to:
 
One can also query the database to know which package a file in the file system belongs to:
  
  $ pacman -Qo /path/to/a/file
+
  $ pacman -Qo ''/path/to/file_name''
  
 
To list all packages no longer required as dependencies (orphans):
 
To list all packages no longer required as dependencies (orphans):
Line 290: Line 286:
 
{{Tip|As an alternative to both the {{ic|-Sc}} and {{ic|-Scc}} switches, consider using {{ic|paccache}} from {{pkg|pacman-contrib}}. This offers more control over what and how many packages are deleted. Run {{ic|paccache -h}} for instructions.}}
 
{{Tip|As an alternative to both the {{ic|-Sc}} and {{ic|-Scc}} switches, consider using {{ic|paccache}} from {{pkg|pacman-contrib}}. This offers more control over what and how many packages are deleted. Run {{ic|paccache -h}} for instructions.}}
  
===Partial upgrades are unsupported===
+
=== Partial upgrades are unsupported ===
 +
 
 
Arch Linux is a rolling release, and new [[Wikipedia:Library (computing)|library]] versions will be pushed to the repositories. The developers and Trusted Users will rebuild all the packages in the repositories that need to be rebuilt against the libraries. If the system has locally installed packages (such as [[Arch User Repository|AUR]] packages), users will need to rebuild them when their dependencies receive a [[Wikipedia:soname|soname]] bump.
 
Arch Linux is a rolling release, and new [[Wikipedia:Library (computing)|library]] versions will be pushed to the repositories. The developers and Trusted Users will rebuild all the packages in the repositories that need to be rebuilt against the libraries. If the system has locally installed packages (such as [[Arch User Repository|AUR]] packages), users will need to rebuild them when their dependencies receive a [[Wikipedia:soname|soname]] bump.
  
Line 298: Line 295:
  
 
== Troubleshooting ==
 
== Troubleshooting ==
 +
 
{{FAQ
 
{{FAQ
 
|question=An update to package XYZ broke my system!
 
|question=An update to package XYZ broke my system!
 
|answer=Arch Linux is a rolling-release cutting-edge distribution. Package updates are available as soon as they are deemed stable enough for general use. However, updates sometimes require user intervention: configuration files may need to be updated, optional dependencies may change, etc.
 
|answer=Arch Linux is a rolling-release cutting-edge distribution. Package updates are available as soon as they are deemed stable enough for general use. However, updates sometimes require user intervention: configuration files may need to be updated, optional dependencies may change, etc.
  
The most important tip to remember is to not "blindly" update Arch systems. Always read the list of packages to be updated. Note whether "critical" packages are going to be updated ({{ic|linux}}, {{ic|xorg-server}}, and so on). If so, it is usually a good idea to check for any news at https://www.archlinux.org/ and scan recent forum posts to see if people are experiencing problems as a result of an update.
+
The most important tip to remember is to not "blindly" update Arch systems. Always read the list of packages to be updated. Note whether "critical" packages are going to be updated ({{Pkg|linux}}, {{Pkg|xorg-server}}, and so on). If so, it is usually a good idea to check for any news at https://www.archlinux.org/ and scan recent forum posts to see if people are experiencing problems as a result of an update.
  
 
If a package update is expected/known to cause problems, packagers will ensure that pacman displays an appropriate message when the package is updated. If experiencing trouble after an update, double-check pacman's output by looking at the log ({{ic|/var/log/pacman.log}}).  
 
If a package update is expected/known to cause problems, packagers will ensure that pacman displays an appropriate message when the package is updated. If experiencing trouble after an update, double-check pacman's output by looking at the log ({{ic|/var/log/pacman.log}}).  
Line 354: Line 352:
 
{{FAQ
 
{{FAQ
 
|question=I installed software using "make install"; these files do not belong to any package!
 
|question=I installed software using "make install"; these files do not belong to any package!
|answer=If receiving a "conflicting files" error, note that pacman will overwrite manually-installed software if supplied with the {{ic|-f}} switch ({{ic|pacman -Sf}}). See [[Pacman Tips#Identify files not owned by any package]] for a script that searches the file system for ''disowned'' files.}}
+
|answer=If receiving a "conflicting files" error, note that pacman will overwrite manually-installed software if supplied with the {{ic|--force}} switch ({{ic|pacman -S --force}}). See [[Pacman Tips#Identify files not owned by any package]] for a script that searches the file system for ''disowned'' files.
 +
{{Warning|Take care when using the {{ic|--force}} switch because it can cause major problems if used improperly.}}}}
  
 
{{FAQ
 
{{FAQ
Line 378: Line 377:
 
'''2.''' If that doesn't work, from a 2012 Arch release (CD/DVD or USB stick), run:
 
'''2.''' If that doesn't work, from a 2012 Arch release (CD/DVD or USB stick), run:
  
: {{Note|If you don't have a 2012 release or if you only have some other "live" Linux distribution laying around, you can [[chroot]] using the old fashion way. Obviously, there will be more typing than simply running the {{ic|arch-chroot}} script.}}{{bc|<nowiki>
+
: {{Note|If you don't have a 2012 release or if you only have some other "live" Linux distribution laying around, you can [[chroot]] using the old fashion way. Obviously, there will be more typing than simply running the {{ic|arch-chroot}} script.}}
 +
 
 +
: {{bc|<nowiki>
 
# mount /dev/sdxY /mnt        #Your root partition.
 
# mount /dev/sdxY /mnt        #Your root partition.
 
# mount /dev/sdxZ /mnt/boot    #If you use a separate /boot partition.
 
# mount /dev/sdxZ /mnt/boot    #If you use a separate /boot partition.
 
# arch-chroot /mnt
 
# arch-chroot /mnt
# pacman -Syu mkinitcpio systemd-tools linux</nowiki>}}
+
# pacman -Syu mkinitcpio systemd linux</nowiki>}}
 +
 
 +
: Reinstalling the kernel (the {{Pkg|linux}} package) will automatically re-generate the initramfs image with {{ic|mkinitcpio -p linux}}. There is no need to do this separately.
  
 
: Afterwards, it's recommended that you run {{ic|exit}}, {{ic|umount /mnt/{boot,} }} and {{ic|reboot}}.}}
 
: Afterwards, it's recommended that you run {{ic|exit}}, {{ic|umount /mnt/{boot,} }} and {{ic|reboot}}.}}
Line 393: Line 396:
 
|question=I keep getting a "failed to commit transaction (invalid or corrupted package)" error
 
|question=I keep getting a "failed to commit transaction (invalid or corrupted package)" error
 
|answer=Look for {{ic|*.part}} files (partially downloaded packages) in {{ic|/var/cache/pacman/pkg}} and remove them (often caused by usage of custom {{ic|XferCommand}} in {{ic|pacman.conf}}).}}
 
|answer=Look for {{ic|*.part}} files (partially downloaded packages) in {{ic|/var/cache/pacman/pkg}} and remove them (often caused by usage of custom {{ic|XferCommand}} in {{ic|pacman.conf}}).}}
 +
 +
{{FAQ
 +
|question=I get an error every time I use pacman saying 'warning: current locale is invalid; using default "C" locale'. What do I do?
 +
|answer=As the error message says, your locale isn't correctly configured. See [[Locale]].}}
  
 
== See also ==
 
== See also ==
 +
 
* [[Common Applications/Utilities#Package management]]
 
* [[Common Applications/Utilities#Package management]]

Revision as of 21:23, 14 November 2012

Summary help replacing me
Pacman is the Arch Linux package manager. Package managers are used to install, upgrade, and remove software. This article covers basic usage and troubleshooting tips.
Overview
Template:Package management overview
Related
Downgrading Packages
Improve Pacman Performance
Pacman GUI Frontends
Pacman Rosetta
Pacman Tips
Pacman package signing
FAQ#Package Management
pacman-key
Pacnew and Pacsave Files
Resources
libalpm(3) Manual Page
pacman(8) Manual Page
pacman.conf(5) Manual Page
repo-add(8) Manual Page

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 Arch 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 you to download/install packages with a simple command, complete with all required dependencies.

Pacman is written in the C programming language and uses the .pkg.tar.xz package format.

Tip: The official pacman package also contains other useful tools, such as makepkg, pactree, vercmp and more. You can get the full list from pacman -Ql pacman | grep bin

Configuration

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 pacman.conf.

General options

General options are in the [options] section. Read the man page or look in the default pacman.conf for information on what can be done here.

Skip package from being upgraded

To skip upgrading a specific package, specify it as such:

IgnorePkg=linux

For multiple packages use a space-separated list, or use additional IgnorePkg lines.

Skip package group from being upgraded

As with packages, skipping a whole package group is also possible:

IgnoreGroup=gnome

Skip files from being installed to system

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/*

Repositories

This section defines which repositories to use, as referred to in /etc/pacman.conf. They can be stated here directly or included from another file (such as /etc/pacman.d/mirrorlist), thus making it necessary to maintain only one list.

/etc/pacman.conf
#[testing]
#SigLevel = PackageRequired
#Include = /etc/pacman.d/mirrorlist

[core]
SigLevel = PackageRequired
Include = /etc/pacman.d/mirrorlist

[extra]
SigLevel = PackageRequired
Include = /etc/pacman.d/mirrorlist

#[community-testing]
#SigLevel = PackageRequired
#Include = /etc/pacman.d/mirrorlist

[community]
SigLevel = PackageRequired
Include = /etc/pacman.d/mirrorlist

# If you want to run 32 bit applications on your x86_64 system,
# enable the multilib repositories as required here.

#[multilib-testing]
#SigLevel = PackageRequired
#Include = /etc/pacman.d/mirrorlist

#[multilib]
#SigLevel = PackageRequired
#Include = /etc/pacman.d/mirrorlist

# An example of a custom package repository.  See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs
Warning: Care should be taken when using the [testing] repository. It is in active development and updating may cause some packages to stop working. People who use the [testing] repository are encouraged to subscribe to the arch-dev-public mailing list for current information.

Package security

Pacman 4 supports signed packages, which adds an extra layer of security to the packages. To enable signature verification, take a look here.

Usage

What follows is just a small sample of the operations that pacman can perform. To read more examples, refer to man pacman.

Installing packages

Installing specific packages

To install a single package or list of packages (including dependencies), issue the following command:

# pacman -S package_name1 package_name2 ...

Sometimes there are multiple versions of a package in different repositories, e.g. [extra] and [testing]. To install the former version, the repository needs to be defined in front:

# pacman -S extra/package_name

Installing package groups

Some packages belong to a group of packages that can all be installed simultaneously. For example, issuing the command:

# pacman -S gnome

will install all the packages that belong to the gnome group. 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.

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.
Warning: When installing packages, do not refresh the package list without upgrading the system (i.e. pacman -Sy package_name); this can lead to dependency issues. See #Partial upgrades are unsupported and https://bbs.archlinux.org/viewtopic.php?id=89328.

Removing packages

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:

Warning: 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: Pacman will not remove configurations that the application itself creates (for example "dotfiles" in the home folder).

Upgrading packages

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. This command can synchronize the repository databases and update the system's packages (excluding 'local' packages that are not in the configured repositories):

# pacman -Syu
Warning: Instead of immediately updating as soon as updates are available, users must recognize that due to the nature of Arch's rolling release approach, an update may have unforeseen consequences. This means that it is not wise to update if, for example, one is about to deliver an important presentation. Rather, update during free time and be prepared to deal with any problems that may arise.

Pacman is a powerful package management tool, but it does not attempt to handle all corner cases. Read The Arch Way if this causes confusion. Users must be vigilant and take responsibility for maintaining their own system. When performing a system update, it is essential that users read all information output by pacman and use common sense. If a user-modified configuration file needs to be upgraded for a new version of a package, a .pacnew file will be created to avoid overwriting settings modified by the user. Pacman will prompt the user to merge them. These files require manual intervention from the user and it is good practice to handle them right after every package upgrade or removal. See Pacnew and Pacsave Files for more info.

Tip: Remember that pacman's output is logged in /var/log/pacman.log.

Before upgrading, it is advisable to visit the Arch Linux home page to check the latest news (or subscribe to the RSS feed): when updates require out-of-the-ordinary user intervention (more than what can be handled simply by following the instructions given by pacman), an appropriate news post will be made.

If one encounters problems that cannot be solved by these instructions, make sure to search the forum. It is likely that others have encountered the same problem and have posted instructions for solving it.

Querying package databases

Pacman queries the local package database with the -Q flag; see:

$ pacman -Q --help

and queries the sync databases with the -S flag; see:

$ pacman -S --help

Pacman can search for packages in the database, searching both in packages' names and descriptions:

$ pacman -Ss string1 string2 ...

To search for already installed packages:

$ pacman -Qs 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

For packages not installed, use pkgfile.

One can also query the database to know which package a file in the file system belongs to:

$ pacman -Qo /path/to/file_name

To list all packages no longer required as dependencies (orphans):

$ pacman -Qdt

To list a dependency tree of a package:

$ pactree package_name

To list all the packages depending on a package, use whoneeds from pkgtools:

$ whoneeds package_name

Additional commands

Upgrade the system and install a list of packages (one-liner):

# pacman -Syu package_name1 package_name2 ...

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

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

Clean the package cache of packages that are not currently installed (/var/cache/pacman/pkg):

Warning: Only do this if you are sure that the installed packages are stable and that a downgrade will not be necessary, since it will remove all of the old versions from the cache folder, leaving behind only the versions of the packages that are currently installed. This comes in handy in case a future upgrade causes breakage, because you will have the packages that are working right on your system, ready to be installed.
# pacman -Sc

Clean the entire package cache:

Warning: This clears out the entire package cache. Doing this is considered a bad practice, because if you ever need to downgrade something, you will not be able to do so right from the cache folder. You will probably have to use the Arch Rollback Machine.
# pacman -Scc
Tip: As an alternative to both the -Sc and -Scc switches, consider using paccache from pacman-contrib. This offers more control over what and how many packages are deleted. Run paccache -h for instructions.

Partial upgrades are unsupported

Arch Linux is a rolling release, and new library versions will be pushed to the repositories. The developers and Trusted Users will rebuild all the packages in the repositories that need to be rebuilt against the libraries. If the system has locally installed packages (such as AUR packages), users will need to rebuild them when their dependencies receive a soname bump.

This means that partial upgrades are not supported. Do not use pacman -Sy package or any equivalent such as pacman -Sy and then pacman -S package. Always upgrade before installing a package -- particularly if pacman has refreshed the sync repositories. Be very careful when using IgnorePkg and IgnoreGroup for the same reason.

If a partial upgrade scenario has been created, and binaries are broken because they cannot find the libraries they are linked against, do not "fix" the problem simply by symlinking. Libraries receive soname bumps when they are not backwards compatible. A simple pacman -Syu to a properly synced mirror will fix the issue as long as pacman is not broken.

Troubleshooting

Template:FAQ

Template:FAQ

Template:FAQ

Template:FAQ

Template:FAQ

Template:FAQ

Template:FAQ

Template:FAQ

Template:FAQ

Template:FAQ

Template:FAQ

Template:FAQ

Template:FAQ

See also