✦ For everyone, free.

Practical knowledge for real and everyday life

Home

Pacman Package Operations

Pacman Package Operations manage software installation, updates, and removal in Arch Linux, using a simple yet powerful command-line interface.

Pacman Package Operations refer to the set of commands and procedures provided by Pacman, the package manager for Arch Linux and its derivatives, to manage software packages. These operations include installing, updating, upgrading, removing, querying, and managing packages on the system. Pacman works with binary packages and synchronizes package databases, allowing users to efficiently maintain software on their Linux systems.


Installing Packages

Installing Single Packages

Pacman allows users to install packages from the official repositories or local package files. To install a package from the repository, the command is:

pacman -S package_name

Pacman resolves dependencies automatically, downloading and installing all required packages.

Installing Multiple Packages

Multiple packages can be installed in one command by listing them separated by spaces:

pacman -S package1 package2 package3

Installing from Local Files

Pacman can also install packages from local .pkg.tar.zst files using:

pacman -U /path/to/package.pkg.tar.zst

This method bypasses the remote repository.


Updating Packages

Synchronizing Package Databases

Before upgrading packages, it is recommended to synchronize the local package database with remote repositories to get the latest package lists:

pacman -Sy

This fetches updated package databases but does not upgrade packages.

Upgrading Packages

To upgrade all installed packages to their latest versions as per the synchronized database, use:

pacman -Syu

This command first synchronizes the package database (-Sy) and then upgrades all packages (-u).

Partial Upgrades Warning

Partial upgrades, such as upgrading individual packages without synchronizing the database, can cause dependency issues and are discouraged.


Removing Packages

Removing Packages While Keeping Dependencies

To remove a package but leave its dependencies installed, use:

pacman -R package_name

This removes the specified package only.

Removing Packages and Unused Dependencies

To remove a package and its dependencies that are no longer required by other packages, use:

pacman -Rs package_name

This performs a recursive removal to clean up unneeded dependencies.

Force Removing Packages

In some cases, removing packages with broken dependencies requires forcing removal:

pacman -Rdd package_name

This skips dependency checks and can break the system if used unwisely.


Querying Packages

Query Installed Packages

To list all installed packages:

pacman -Q

To query information about a specific installed package:

pacman -Qi package_name

Query Files Owned by a Package

To list files installed by a package:

pacman -Ql package_name

Query Package Ownership of a File

To find which package owns a particular file:

pacman -Qo /path/to/file

Searching for Packages in Repositories

To search for packages by name or description in remote repositories:

pacman -Ss search_term

Managing Package Caches and Databases

Cleaning Package Cache

Pacman stores downloaded packages in a cache directory. To remove old or unused package files:

pacman -Sc

This removes packages not currently installed.

To remove all cached packages except the most recent version:

pacman -Scc

Warning: this removes all cached packages and can make downgrading or reinstalling packages without internet access impossible.

Refreshing Package Databases

To force refresh the package databases without upgrading:

pacman -Sy

Use with caution to avoid partial upgrades.


Handling Package Conflicts and Dependencies

Resolving Dependencies

Pacman automatically resolves dependencies during install or upgrade operations, downloading required packages as needed.

Handling Conflicts

If package conflicts occur, pacman will report files that conflict with existing packages. Users must resolve these conflicts manually, such as by removing conflicting packages or files.


Additional Package Operations

Downgrading Packages

Pacman does not support downgrading packages directly from the official repositories. Users must manually download older package versions and install them with:

pacman -U /path/to/older_package.pkg.tar.zst

Verifying Package Integrity

To verify the integrity and authenticity of installed packages:

pacman -Qk package_name

This checks for missing files or altered files in the package.


Common Pacman Command Options Summary

OptionDescription
-SSynchronize and install packages
-UInstall package from a local file
-RRemove package
-RsRemove package and dependencies
-QQuery installed packages
-SsSearch packages in remote repositories
-SySynchronize package databases
-SyuSynchronize and upgrade all packages
-ScClean package cache (remove uninstalled packages)
-SccClear entire package cache
-QiDisplay detailed info about a package
-QlList files owned by a package
-QoFind package owning a file

Pacman Package Operations form the fundamental toolkit for maintaining software on Arch Linux systems, providing efficient, consistent, and dependency-aware package management through a straightforward command-line interface.