LinuxCommandLibrary

pacman

Manage software packages (install, update, remove)

TLDR

[S]ynchronize and update all packages

$ sudo pacman -Syu
copy

Install a new package
$ sudo pacman -S [package]
copy

[R]emove a package and its dependencies
$ sudo pacman -Rs [package]
copy

Search ([s]) the package database for a regex or keyword
$ pacman -Ss "[search_pattern]"
copy

Search the database for packages containing a specific [F]ile
$ pacman -F "[file_name]"
copy

List only the [e]xplicitly installed packages and versions
$ pacman -Qe
copy

List orphan packages (installed as [d]ependencies but not actually required by any package)
$ pacman -Qtdq
copy

Empty the entire pacman cache
$ sudo pacman -Scc
copy

SYNOPSIS

pacman [generic_options] [{command [options] [targets]}]

PARAMETERS

-S
    Sync: install/upgrade packages from repos

-R
    Remove packages (no deps by default)

-Q
    Query installed packages

-U
    Upgrade/install local .pkg.tar.zst package

-Fs
    Search files owned by packages in sync DB

-F
    Search files in sync DB

-D
    Modify package database (e.g., mark explicit)

-T
    Test dependencies

--sysupgrade
    Upgrade all packages (-Su)

--refresh
    Refresh sync DB (-Syy)

--needed
    Skip installed packages

--overwrite
    Overwrite conflicting files

-b
    Alternative root prefix

-c


    Cache directory

-d
    Skip dependency checks

--debug
    Enable debug output

-q
    Quiet mode

--noconfirm
    No confirmation prompts

-v
    Verbose output

--print
    Print targets instead of acting

DESCRIPTION

pacman is the default package manager for Arch Linux and its derivatives. It serves as a front-end to libalpm, a C library for package management. Pacman handles installing, updating, removing, and querying packages from both official repositories and local files. Key features include support for split packages (one source yielding multiple binaries), automatic dependency resolution, file conflict detection, and progress bars.

It operates in several modes: synchronization (-S), removal (-R), querying (-Q), file searches (-F/-Fs), and local upgrades (-U). Common workflows include pacman -Syu for full system upgrades (sync databases, then upgrade all packages) and pacman -S package for installing specific ones. Pacman requires root privileges for most operations and uses pacman.conf(5) for configuration, defining repositories, mirrors, and caches.

Pacman emphasizes simplicity, speed, and rolling-release model suitability. It downloads packages as .pkg.tar.zst, verifies checksums and signatures, then extracts to the filesystem. Orphan detection, explicit package marking, and hooks for pre/post actions enhance usability. While powerful, it demands caution to avoid dependency breakage.

CAVEATS

Requires root for most ops; always run pacman -Syu for upgrades; partial upgrades risky; GPG keys must be imported for signatures.

DATABASES

Sync DBs in /var/lib/pacman/sync/; local DB in /var/lib/pacman/; refresh with -Sy.

HOOKS

Custom scripts in /usr/share/libalpm/hooks/ run pre/post operations.

HISTORY

Developed by Judd Vint (2002-2006) for Arch Linux; rewritten in C; maintained by Pacman Development Team since 2006; version 6.x supports zstd compression.

SEE ALSO

makepkg(8), pacman.conf(5), libalpm(3), repo-add(8)

Copied to clipboard