[go: up one dir, main page]

0% found this document useful (0 votes)
26 views8 pages

Archlinux Pacman Command

This document describes pacman, the package manager of Archlinux. It explains how to configure and use pacman to install, update, and remove packages, and provides examples of pacman commands.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views8 pages

Archlinux Pacman Command

This document describes pacman, the package manager of Archlinux. It explains how to configure and use pacman to install, update, and remove packages, and provides examples of pacman commands.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Introduction to Pacman

pacmanis the package manager of Archlinux. It combines a set of binary tools with a system
relatively simple to build packages. (seemakepkgandABSThe aim is to easily manage the packages,
whether they come from official repositories or are compiled by the user.

pacman allows you to keep your system up to date by synchronizing the package list from a server and then
download/install the new packages, as well as their dependencies, with a simple command.

Configuration
Pacman is configured using the file /etc/pacman.conf (cf.man 5 pacman.conf).

Global options
These options are configured under the [options] section, some examples:

 Architecture: if it is defined, pacman will only install packages of this architecture. It can take the
auto value (the architecture will be defined by a call touname -m). It also allows the use of the
variable$archin theURIof adeposit.
 IgnorePkg: indicates to pacman the packages not to update.
 IgnoreGroup: indicates to pacman the groups to not update.
 UseDelta: this option does not take any parameters and allows the user to indicate to download the deltas
packages if they are available. (cf.Use of deltas)
 SigLevel: Indicate topacmanhow to manage signatures:pacman-key
 Color: the output of pacman in the console will be colored.
 Indicate topacmannot to extract certain files (e.g.Prevent the installation of locales)

Deposits
The syntax is simple:

[name_of_the_deposit]
Server=mirror1_of_the_repository
Server=mirror2_of_the_depot

Note: Regarding the indicated URL, pacman automatically replaces $repo with the name of the repository.

and$search for the configured architecture.

Note: The Include directive allows including another file in the configuration; in practice, the content of the file

target replaces the line of the directive.

cf.Deposit details.

Usage
Note: Since Archlinux is a rolling release, updating the system may require action.

manual unlike regular release distributions, it is therefore important to follow certain rules of

bases :
 read thenewsOn the homepage, updates requiring particular action are usually the subject of

of an article.

 read the output of pacman (which is kept in the log,/var/log/pacman.log)

 tprocess the configuration files(.pacnew, .pacsave, .pacorig) when necessary

 know how to recognize critical packages and, depending on skills, maybe wait a minimum of time before

update these packages. (While others are struggling with it :p)

For a complete description, please refer to the man page:pacman(8)Some options need to be taken
with great caution, consultthese a few tipsto use pacman optimally.

Here are some examples of operations:

Package database synchronization


This operation updates the list of available packages on themirrors:

pacman -Sy

Package installation
Installation of a package list:

pacman -S package_1 package_2

If the package exists in several repositories, one can possibly specify one:

pacman -S extra/package

If you have the archive of a package on your disk:

pacman -U package_archive.pkg.tar.xz

Or even if you have the link to the archive, for example:

pacman -UThe provided text is a URL and does not contain translatable content.

For the installation of a list of packages from a text file (one package per line):

pacman -S - < pkglist.txt

It is also possible to do this if the number of packets is not too large:

pacman -S $(cat pkglist.txt)

Package updates
Update following a previously performed synchronization:

pacman -Su

Synchronization then, update:


pacman -Syu

To install a new package while updating the system:

pacman -Syu package_1

Packet suppression
pacman -R package_1

To keep a system clean, it is also necessary to remove dependencies that are no longer required by any package:

pacman -Rs package_1

By default, modified configuration files are saved with the .pacsave extension. To not...
to conserve

pacman -Rsn package_1

Note: Pacman does not touch personal directories; it is the user's responsibility to handle all files.

configuration that would be found there.

Research
For quick assistance:

pacman -Q --help
pacman -S --help
pacman -R --help

Searching for a package among those installed:

pacman -Qs package

Searching for a package in the repositories:

pacman -Ss package

pacman can perform a search with regular expressions:

$ pacman -Ss gn.me win.*manager

extra/mutter 3.14.1.5-1 (gnome)

A window manager for GNOME

community/metacity 3.14.1-1

Legacy GNOME window manager

Complete information about an installed package (for example, to check if some optional dependencies
can provide you with additional features):

pacman -Qi package


or not:

pacman -Si package

Tip: with-QiiYou can know the possible backup files of a package and their status.

with-Qii|grep ^MODIFIEDyou can know all backup files modified compared to those

of origin.

List of files in an installed package:

pacman -Ql package_1

To know which package one of the system files belongs to:

pacman -Qo /path/to/file

Tip:pkgfileallows you to search for a file in the not installed packages, or to list the files of a

package not installed with the -l option.

List of packages not belonging to any repository configured in pacman.conf:

pacman -Qm

List of packages (dependencies) that are no longer required by the system (the package that caused their installation is no longer
present)

pacman -Qdt

Attention: List the packages that are not explicitly installed and that no other package depends on, but this does not

doesn't necessarily mean that you don't use them. For example, you install a package that depends on dezip, this

last installs, one day, he no longer depends on it, zip will become not required by the system, but you may still use it.

still. (cfModification of the databasebelow

Downgrade packages
It is sometimes necessary to temporarily revert to the previous version of a package (regression, bug), different
existing means:Downgrade.

Clean the package cache


pacman stores the downloaded packages here/var/cache/pacman/pkg/and does not automatically remove the versions
old or uninstalled. Therefore, it is necessary to regularly empty this folder to prevent it from taking up space.
excessive.

The following pacman command removes all non-installed packages from the cache (old versions or not.
installed on the system)

pacman -Sc
Attention :

 Only run this command if you are sure that the installed packages are stable on your system and

that onedowngradewill not be necessary. This will remove all the old versions of the packages by not

leaving only the last installed versions. It may be useful to keep the old versions of the packages.

cases where an update would make the system unstable or inoperable.Murphy's Law always applying in this

This happens just after a complete cache clearing. If all the old packages have been removed from

cache, the only way to recover them is to go through an alternative repository likeArch Rollback Machine.

 It is also possible to completely clear the cache using the command pacman -Scc. This prevents any

Reinstallation of packages from the cache requires them to be downloaded again, which is not a problem.

thanks toArch Rollback MachineSo quite useful in order to recover disk space.

Due to all the restrictions stated above, it is recommended to use a dedicated cache cleaning script.
from pacman, in order to more finely control the packages to be removed:

 The commandpaccache, provided with the packagepacman-contrib, delete by default all packages from the cache except
the three latest versions:
paccache -r

However, it will not verify if the packages are still installed on the system and will therefore leave the packages.
not installed in the cache. To remove from the cache all versions of the non-installed packages, you must run
the following command at a later time:

paccache -ruk0

Seepaccache -hp for more options.

 You can also install and use the alternative scripts:pkgcacheclean(written in C)...
pkgcacheclean

 orpacleaner(written in python) sinceAUR:


To verify the packages to be removed except for the three most recent:

pacleaner -m

To check the non-installed packages:

pacleaner -u

Use the --delete option to remove packages:

pacleaner -m --delete
pacleaner -u --delete

Default options can be modified in a configuration file (number of packets to keep,


access path to the cache...)
Modification of the database
You can modify certain elements of the database of installed packages, including the reason
of installing a package (installed as dependencies or explicitly):

pacman -D --asexplicit package_1 package_2


pacman -D --asdeps package_1 package_2

In bulk
 Download packages only:
pacman -Sw package_1 package_2

 Check that no installed files are missing across all packages:


pacman -Qqk

A completely useless and (perhaps) indispensable trick...


There is a little trick with Pacman that — I am sure — you will be eager to try. Edit the file.
"/etc/pacman.conf" and add the option "ILoveCandy" in the section below "[options]" :

options
ILoveCandy

You will subsequently obtain a Pacman output similar to the game of the same name when you set up your system
up to date.

Prevent the installation of locales


The NoExtract option of the filepacman.confis very useful if certain parts of packages are unnecessary for you. The
Locales are a typical case of this type of files that one might want to do without.

None of the files listed in the NoExtract option rules are extracted during the installation of a package.
pattern* is allowed to designate a set of files (as one would do in a shell). By
example /usr/lib/systemd/system/* designates all the files in the folder/usr/lib/systemd/system/thus
that in its subfolders. It is possible to reverse the behavior of a rule by prefixing it with a !. This cancels
the previous rules regarding the corresponding files.

So, if we want to do without all the locales except for the Francophone ones, we obtain the following rules to add
in the section [options] ofpacman.conf.

/etc/pacman.conf file

NoExtract = usr/share/locale/[a-z]*/*
!usr/share/locale/fr/*
!usr/share/locale/fr_FR/*
The rules can also be indicated on a single line.

Note: Adding these lines does not make the files disappear until the packages containing them are updated.

day.
However, it is possible to delete them directly with, for example, the following command:find

/usr/share/locale/* -maxdepth 0 -type d ! -name fr ! -name fr_FR -print0 |xargs -0 rm -r

Retrieve the sources of a package


Note: Valid for all packages located at this address[1]

( Invalid text for translation. Please provide translatable content.)

git clone --branch packages/package_name --single-branch


The provided text is a URL and does not contain translatable content. package_name

Only the package name is required. This allows us to obtain the Pkgbuild after which we can enter the command.
next to retrieve the sources:

makepkg -S

Problems
Pacman crash during an update
In the event that pacman crashes during an update, package removal, or even a reinstallation of a
package, you will need to complete these different steps:

 Boot from an ArchLinux installation ISO


 Mount your root files system/, /boot, /var, etc., if they exist)
 Update your pacman database as well as update your packages via the commandpacman -r
/path/to/root -Syyu
 Reinstall the broken package(s) using the commandpacman -r /path/to/root -S package

A package has been updated but pacman says the system is up to date
The Pacman mirrors are not directly synchronized. It takes about 24 hours before you can
to receive the much-desired update.

The package is not found


First, make sure that the package you are trying to install actually exists. If this package does indeed exist,
check that the spelling is correct. It may also be that the package exists and the spelling is correct but that
the list of your packages is outdated. In this case, a simple pacman -Syyu will suffice.

The same package is continuously updating.


This problem is due to duplicate entries in /var/lib/pacman/local/ as if there were two instances of linux.
The command pacman -Q gives the correct version and the command pacman -Q recognizes the oldest.
versionE Try to update it. The solution is therefore to delete the wrong entry in /var/lib/pacman/local/

Equivalences between Pacman and other package managers


packages
If you are used to using Arch, Red Hat/Fedora, Debian/Ubuntu, SUSE/openSUSE or even Gentoo, and that
you are having difficulty getting to grips with the package manager but you are comfortable with a
other, you can consult the pagePacman Rosetta, which provides the equivalent commands between each of the
package managers.

If you are very comfortable with Pacman but cannot manage to use other package managers...
mainpacaptis a solution.

You might also like