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 regular expression 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 operation [options] [targets]

Common operations include:
pacman -S [options] package(s) (Sync/Install)
pacman -R [options] package(s) (Remove)
pacman -U [options] package(s) (Upgrade/Install local)
pacman -Q [options] package(s) (Query)
pacman -F [options] file(s) (Files query)

PARAMETERS

-S, --sync
    Synchronizes packages with remote repositories. Used for installing new packages (e.g., pacman -S package), refreshing package databases (pacman -Sy), or performing a full system upgrade (pacman -Syu).

-R, --remove
    Removes packages from the system. Can also remove dependencies no longer required by other installed packages (e.g., pacman -Rs package) or configuration files (pacman -Rns package).

-U, --upgrade
    Installs or upgrades a package from a local file (e.g., a downloaded .pkg.tar.zst file). Useful for custom-built packages or those not in official repositories. Example: pacman -U /path/to/package-1.0-1.pkg.tar.zst.

-Q, --query
    Queries the local package database for installed packages. Used to list installed packages (pacman -Q), show detailed information about a package (pacman -Qi package), or list files owned by a package (pacman -Ql package).

-F, --files
    Queries the remote files database to find which package owns a specific file, or to search for files within packages. Example: pacman -F /usr/bin/ls.

-D, --database
    Performs various database maintenance tasks, such as checking package integrity, verifying dependencies, or changing the install reason of a package (e.g., marking as explicitly installed or a dependency).

-V, --version
    Displays the pacman version and build information.

-h, --help
    Displays a short help message with common command-line options and their usage.

DESCRIPTION

pacman (Package Manager) is the default package manager for Arch Linux and its derivatives. Written in C, it's designed to be simple, fast, and easy to use. It manages software packages, dependencies, and updates through a local database synchronized with remote repositories.

It combines a simple binary package format with an easy-to-use build system (makepkg), enabling users to build packages from source or install pre-compiled binaries. pacman efficiently handles package installation, removal, upgrades, and queries, making system maintenance straightforward in a rolling release environment.

CAVEATS

Most pacman operations (installation, removal, system updates) require root privileges, typically invoked with sudo.

Partial upgrades are not supported and can lead to system instability; always perform a full system synchronization and update using pacman -Syu.

As Arch Linux is a rolling release, regular updates are crucial to maintain a stable and secure system, and to benefit from the latest features and bug fixes.

ROLLING RELEASE MODEL

Arch Linux operates on a rolling release model, meaning there are no distinct 'versions' of the operating system. Instead, pacman -Syu continuously updates the system with the latest software and libraries, ensuring users always have access to the most current stable software without reinstallations.

ARCH USER REPOSITORY (AUR)

While pacman directly manages packages from official repositories, the Arch User Repository (AUR) is a community-driven collection of PKGBUILD scripts that allow users to compile and install software not available in the official repos. Users often employ 'AUR helpers' (e.g., yay, paru) to automate the process of building and installing AUR packages, which internally leverage makepkg and pacman.

CONFIGURATION

pacman's behavior, including repository definitions, mirror lists, and various system-wide options (e.g., `Color`, `ParallelDownloads`), is configured via the /etc/pacman.conf file. Users can customize this file to tailor pacman's operation to their specific needs and location.

HISTORY

pacman was initially developed by Judd Vinet, the founder of Arch Linux, and first released in 2002. It was designed from the ground up to be the core package manager for Arch Linux, emphasizing simplicity, speed, and user control over the system. Written in C, it has remained central to Arch Linux's design philosophy, constantly evolving alongside the distribution while maintaining its core principles.

SEE ALSO

makepkg(8), pacman.conf(5), pkgbuild(5)

Copied to clipboard