✦ For everyone, free.

Practical knowledge for real and everyday life

Home

pacman

pacman is a package manager for Arch Linux that automates software installation, updates, and dependency resolution.

pacman is the package manager utility designed for Arch Linux and its derivatives. It is responsible for installing, updating, removing, and managing software packages in a binary format through a simple command-line interface. pacman maintains the system's package database, resolves dependencies automatically, and ensures consistency and integrity of installed packages by using package signatures and checksums.


Overview of pacman

pacman combines a simple binary package format with an easy-to-use build system. It automates the process of software installation, updating, and removal by interacting with remote repositories and a local package database. This enables Arch Linux users to keep their systems up-to-date and clean with minimal effort.

The core features of pacman include:

  • Dependency resolution to ensure all required libraries and packages are installed.
  • Synchronization with remote repositories, allowing users to update the system or install new software.
  • Transactional package operations that guarantee atomic upgrades and rollback in case of failure.
  • Support for package signing and verification to ensure software authenticity and integrity.
  • Efficient package caching and database management to optimize disk usage and performance.

Basic pacman Usage

Installing Packages

To install packages, pacman uses the -S flag followed by the package name(s). It retrieves the latest version from the configured repositories, downloads it, resolves dependencies, and installs everything automatically.

pacman -S package_name

Multiple packages can be installed in a single command by listing them with spaces.

Removing Packages

Packages can be removed using -R option. The command removes the specified package but leaves dependencies by default.

pacman -R package_name

To remove the package and its unused dependencies, the -Rs option is used.

pacman -Rs package_name

Updating the System

To update the entire system and all installed packages to their latest versions from the repositories, the -Syu option is used.

pacman -Syu

This command synchronizes the local package database with the remote repositories (-Sy), then performs a full system upgrade (-u).

Querying Packages

To query installed packages, pacman provides the -Q option, which can be combined with various subcommands for detailed information:

  • pacman -Q package_name shows if a package is installed and its version.
  • pacman -Qi package_name provides detailed information about a package.
  • pacman -Qs search_term searches for packages in the database matching a term.
  • pacman -Ql package_name lists all files installed by a package.

Package Management Details

Package Format

pacman uses .pkg.tar.zst or .pkg.tar.xz compressed tar archives that contain precompiled binaries and metadata. Each package archive includes:

  • desc file: package metadata such as name, version, description, dependencies, etc.
  • Files: the actual program files and assets to install.
  • Checksums and signature files for verifying package integrity and authenticity.

Package Database

The local package database is stored in /var/lib/pacman/local/ and maintains metadata for all installed packages. pacman uses this database to track installed versions, dependencies, and to detect orphaned packages.

Remote repository databases, which contain available package metadata, are downloaded and cached in /var/lib/pacman/sync/.

Dependency Resolution

pacman automatically resolves and installs required dependencies when adding a package. It considers version constraints and prevents conflicts by carefully managing package relationships. If conflicting packages exist, pacman will refuse to proceed unless the user explicitly resolves the issue.

Package Signing and Verification

Security is ensured through package signing using GPG. Packages and repository databases are signed by trusted keys, which pacman verifies before installation. This process prevents tampering and guarantees the authenticity of packages.


Configuration and Customization

Configuration File

pacman’s behavior is controlled by the configuration file /etc/pacman.conf. This file specifies:

  • Repository definitions and priorities.
  • Package caching policies.
  • Options for signature checking.
  • Hooks and scripts for pre/post package operations.

Users can add custom repositories or enable additional features by editing this file.

Hooks and Scripting

pacman supports hooks that trigger scripts before or after package operations. These hooks automate maintenance tasks such as updating system caches, rebuilding font lists, or cleaning temporary files.

Hooks are defined in /etc/pacman.d/hooks/ and are useful for extending pacman functionality without user intervention.


Advanced Features

Transactional Package Operations

pacman performs package installations, removals, and upgrades as atomic transactions. This means that if a package operation fails midway, pacman will roll back changes to maintain system stability and consistency.

Cache Management

pacman stores downloaded package files in /var/cache/pacman/pkg/. This cache allows reinstalling packages without re-downloading. Users can clean the cache manually or use pacman -Sc to remove old packages, or pacman -Scc to clear the entire cache.

Handling Orphaned Packages

Orphaned packages are those installed as dependencies but no longer required by any installed package. pacman can detect these with pacman -Qdt and remove them with pacman -Rns to keep the system clean.


Common pacman Command Summary

CommandDescription
pacman -S packageInstall package(s)
pacman -R packageRemove package
pacman -Rs packageRemove package and dependencies
pacman -SyuSynchronize and update the system
pacman -Q packageQuery installed package
pacman -Qi packageDetailed package info
pacman -Qs searchSearch packages in repositories
pacman -Ql packageList files installed by a package
pacman -QdtList orphaned packages
pacman -ScClean cache of old packages
pacman -SccClear entire package cache

Summary

pacman is an efficient, robust, and flexible package manager designed to streamline package management on Arch Linux systems. It automates complex tasks like dependency resolution, package verification, and system updates while providing powerful options to query and maintain the system. Its design allows users to keep their system minimal, secure, and always up-to-date with ease.