LinuxCommandLibrary

pacman-r

Remove packages from the system

TLDR

View documentation for the original command

$ tldr pacman remove
copy

SYNOPSIS

pacman -r [operation] [options] [targets]
Example: pacman -r /mnt -S linux

PARAMETERS

-r
    The primary option that specifies an alternative root directory for all subsequent pacman operations. All paths accessed by pacman (configuration, databases, package installation) will be relative to this root.

--root
    Long form equivalent of -r, also specifies an alternative root directory for pacman operations.

[operation]
    Any standard pacman operation, such as -S (sync/install), -R (remove), -Q (query), -U (upgrade local package), etc. These operations are performed relative to the specified root.

[options]
    Additional pacman options that modify the behavior of the operation (e.g., --noconfirm, --cachedir, --config). These options also apply relative to the alternative root.

[targets]
    The specific packages or package groups to act upon, relative to the specified root. For example, a package name for installation or removal.

DESCRIPTION

pacman is the official package manager for Arch Linux and its derivatives. The -r or --root option allows users to perform package management operations (such as installing, removing, or querying packages) on a system root other than the currently running one. This feature is invaluable for various administrative and recovery tasks, including:

System Recovery: Managing a broken system by booting from a live environment and using pacman -r to fix issues in the installed system.

Chroot Environments: Installing or updating packages within a chroot, which is a common practice for building software, testing, or performing system maintenance in an isolated environment.

Parallel Installations: Administering multiple Arch Linux installations from a single running system.

When used, pacman will search for its configuration files (e.g., pacman.conf) and package databases within the specified root directory, rather than the standard / path. This powerful capability ensures precise control over where packages are installed and from which system's perspective the operation is performed, making it a critical tool for advanced Arch Linux users and administrators.

CAVEATS

When using pacman -r, it is crucial to ensure that the specified root directory () has a proper Linux Filesystem Hierarchy Standard (FHS) structure. The pacman.conf file must exist within /etc/pacman.conf, and the package database should be located at /var/lib/pacman. Incorrect setup can lead to package database inconsistencies, broken installations, or unintended modifications to the alternative system. Permissions must be correctly managed for successful operations. While pacman -r manages packages in the specified root, it does not automatically chroot into it; for a full chroot environment setup, tools like arch-chroot or manual chroot are often used in conjunction.

CONFIGURATION FILES AND DATABASE LOCATION

When pacman -r is invoked, it specifically looks for its configuration file at /etc/pacman.conf and its package database at /var/lib/pacman. Users must ensure these directories and files are correctly set up within the alternative root for pacman operations to function as expected. If the configuration file is not at the standard path within the alternative root, the --config option can be used to specify its exact location.

HISTORY

pacman was created by Judd Vinet and first released in 2002 as the core package manager for Arch Linux, emphasizing simplicity, speed, and reliability. The --root (or -r) option has been a fundamental part of pacman since its early development. This capability reflects the critical need for robust system recovery and management outside of a fully operational live environment, which is a common scenario in system administration. Its importance has grown significantly with the widespread adoption of chroot environments for software development, testing, and system maintenance tasks within the Arch Linux community.

SEE ALSO

Copied to clipboard