Difference between revisions of "Pacman"

From ArchWiki
Jump to: navigation, search
m (Troubleshooting)
(Troubleshooting)
Line 270: Line 270:
 
|question=I need to run pacman-key --init over ssh.  How can I collect entropy?
 
|question=I need to run pacman-key --init over ssh.  How can I collect entropy?
 
|answer=Build and install the {{AUR|rng-tools}} package from the [[AUR]] on the target machine.  Connect via ssh and do the following:
 
|answer=Build and install the {{AUR|rng-tools}} package from the [[AUR]] on the target machine.  Connect via ssh and do the following:
  # sed -i 's/0/10/' /etc/conf.d/rngd
+
  sed -i 's/0/10/' /etc/conf.d/rngd
  # rngd -f -r /dev/urandom &
+
  rngd -f -r /dev/urandom &
  # pacman-key --init
+
  pacman-key --init
  
 
After pacman-key successfully runs simply stop rngd and remove the package.
 
After pacman-key successfully runs simply stop rngd and remove the package.
  
  # killall rngd
+
  killall rngd
  # pacman -Rns rng-tools
+
  pacman -Rns rng-tools
  
Pacman4 is now ready for use.}}
+
{{Note|The standard # mark to denote the command should be executed as the root user has been omitted from the above instructions purposely to allow easy copy/paste into an ssh terminal.}}}}
  
 
{{FAQ
 
{{FAQ

Revision as of 11:49, 21 January 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

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
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 main features of Arch Linux. It combines a simple binary package format with an easy-to-use build system (see makepkg and Arch 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 contains also other useful tools, such as makepkg, pactree, vercomp and more. You can get the full list from pacman -Ql pacman | grep bin

Configuration

pacman configuration is 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

Repositories

This section defines which repositories to use, as referred to in pacman.conf. They can be stated here directly, or included from another file.

All official repositories use the same /etc/pacman.d/mirrorlist file which uses the $repo variable, making it necessary to maintain only one list.

The following is an example for the official repositories that defers mirrors to /etc/pacman.d/mirrorlist.

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

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

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

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

[community]
#SigLevel = PackageOptional
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 = PackageOptional
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
Note: 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.

Usage

To read other examples of what pacman can do, refer to man pacman. The examples below are just a small sample of operations that can be performed.

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]). Specify which one to install:

# pacman -S extra/package_name
# pacman -S testing/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: Do not refresh the package list when installing packages (i.e. pacman -Sy package_name); this can lead to dependency issues.[1] Upgrade explicitly first; before installing new packages.

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:

# 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, pacman will prompt the user to merge a pacnew file.

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 from pkgtools package or nosr from nosr-gitAUR from AUR.

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

$ pacman -Qo /path/to/a/file

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 needed by 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 repository:

# pacman -U /path/to/package/package_name-version.pkg.tar.xz

Install a 'remote' package (not from a repository):

# 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 sure that the current versions of installed packages are stable and a downgrade is not needed as pacman -Sc removes all the old versions of installed packages.
# pacman -Sc

Clean the entire package cache:

Warning: This clears the entire package cache. Doing this is a bad practice since it removes the ability to downgrade to the current set of packages in the case that an upgrade causes breakage.
# pacman -Scc

As an alternative to both the -Sc and -Scc' switches, consider using CachecleanAUR from the AUR. This python script selectively cleans pacman's cache keeping x old version of each package therein.

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