Grokking Pacman
Introduction
Pacman (Arch Linux package manager) is the official front end of libalpm(3), the ‘Arch Linux Package
Management’ library. It uses tar.xz
format as binary package format for simplicity and ease of use. Conventionally
prefixed pkg
for denoting pacman package ie. grep-3.1.1-x86_64.pkg.tar.xz
.
Usage
Show pacman version
$ pacman -V
Print Root, Conf File, DB Path, Cache Dirs, etc
$ pacman -v # or --verbose
Following options can be used to alter default path or directory:
Option | Description | Default |
---|---|---|
–root | Program installation root | / |
–config | Configuration file | /etc/pacman.conf |
–dbpath or -b | Sync database directory | /var/lib/pacman/ |
–cachedir | Package cache directory | /var/cache/pacman/pkg/ |
–hookdir | Hooks directory | /etc/pacman.d/hooks/ |
–gnupg | GnuPG directory | /etc/pacman.d/gnupg/ |
–logfile | Action log | /var/log/pacman.log |
Change mirror list in /etc/pacman.d/mirrorlist
as mirror precedence is order based.
Query Installed Packages
Query details about locally installed packages using –query or -Q.
Show all installed package:
$ pacman -Q
List can be filtered using:
-d | Packages installed as dependency |
-e | Explicitly installed packages |
-n | Packages installed form sync database |
-m | Installed manually or from AUR |
-g | Package belonging to named group |
-u | Outdated packages |
-t | Not required or optionally required package |
List orphan packages:
$ pacman -Qdt
Print detailed info of package, -ii prints with backup files information:
$ pacman -Qi <package-name>
Print all files of the package, add -q for package name without version:
$ pacman -Ql <package-name>
Print changelog of a package if exist:
$ pacman -Qc <package-name>
Query which package owns the file:
$ pacman -Qo <filename>
Search locally installed packages by name or description using regexp:
$ pacman -Qs <regexp>
Check package required files are present in system:
$ pacman -Qk <package-name>
By default query against local database, -p can be used for binary package.
Executing -i on an binary package:
$ pacman -Qip <package-name>.pkg.tar.xz
Install/Update Repository Packages
Package can be synchronized with remote, including all its dependencies using –sync or -S.
Refresh sync database, -yy will refresh even if up to date:
$ sudo pacman -Sy
Update all outdated packages in system:
$ sudo pacman -Su
Install or update package with all its dependencies. Although not recommended –noconfirm can be used for bypassing confirmation:
$ sudo pacman -S --noconfirm <package-name or group>
Display information from sync database:
$ pacman -Si <package-name>
List all packages of target repository:
$ pacman -Sl <repository-name>
Print name of group with its members, omitting name will print all group:
$ pacman -Sgg <group-name>
Clear unused local package cache, -cc will clear all cache:
$ sudo pacman -Sc
Download packages from the server without install/updating:
$ sudo pacman -Sw <package-name>
Search package by name or description, add -q for only package name:
$ pacman -Ss <regexp>
Install/Update Binary Packages
–upgrade or -U is used for updating or installing binary packages.
Update or install package from local binary package or URL:
$ sudo pacman -U /path/to/package
For downgrading a package, download from Arch Linux Achieve and install like above.
Remove Packages
Remove package by name or group using –remove or -R.
Remove a package or all packages of a group:
$ sudo pacman -R <package-name or group>
Remove package with non required dependencies, add -n for including backup configuration:
$ sudo pacman -Rsn <package-name>
Query Remote Files
Search or Query file details of sync database packages using –files or -F.
Refresh sync packages file database, -yy will refresh even up to date:
$ sudo pacman -Fy
List files of package:
$ pacman -Fl <package-name>
Search for the owner of file:
$ pacman -Fo <filename>
Search filename with regular expression, omitting -x will perform text search:
$ pacman -Fxs <regexp>
Modify Local Database
–database or -D for modifying local package database attribute and internal consistency check.
Check internal database dependency, -Dkk for ensuring all decencies are in sync database:
$ pacman -Dk
Mark package installation reason as dependency. Useful while installing package for AUR dependency:
$ sudo pacman -D --asdeps <package-name>
Package can be marked –asexplicit for keeping a dependent package even when parent package is removed.
Tools Version
- pacman 5.0.2