LinuxCommandLibrary

pacman-query

Query package information from the Arch Linux database

TLDR

[Q]uery the local package database and list installed packages and versions

$ pacman -Q
copy

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

Find which package [o]wns a file
$ pacman -Qo [filename]
copy

Display information about an [i]nstalled package
$ pacman -Qi [package]
copy

Display the [l]ist of files owned by a specific package
$ pacman -Ql [package]
copy

List orphan packages (installed as [d]ependencies but unrequired ([t]) by any package and print in [q]uiet mode (only package name is displayed))
$ pacman -Qdtq
copy

List installed packages foreign ([m]) to the repository database
$ pacman -Qm
copy

List packages that can be [u]pgraded
$ pacman -Qu
copy

SYNOPSIS

pacman -Q [options] [package(s)]

PARAMETERS

-a, --arch
    Query packages of a specific architecture. Requires a target package to be specified.

-c, --changelog
    View the changelog of a package.

-d, --deps
    List dependencies of specified package(s).

-e, --explicit
    List explicitly installed packages.

-g, --groups
    List members of a package group.

-i, --info
    View package information.

-k, --check
    Perform database integrity checks.

-l, --list
    List files installed by a package.

-m, --foreign
    List packages not found in the sync database.

-n, --native
    List packages found in the sync database.

-o, --owns
    Query the package that owns .

-p, --file
    Query a package file instead of the database.

-q, --quiet
    Display less information.

-s, --search
    Search remote repositories for matching packages.

-t, --unrequired
    List packages only required as dependencies.

-u, --upgrades
    List packages that have upgrades available.

-w, --files
    List all files in a package.

DESCRIPTION

pacman-query, or `pacman -Q`, is a command-line utility used to query the Pacman package database in Arch Linux and its derivatives. It allows users to retrieve information about installed packages, including their version, dependencies, architecture, installation date, and more.

It's a powerful tool for package management, enabling users to investigate package details without needing to manually browse files or consult online resources. `pacman -Q` can also be used to identify orphaned packages, list explicitly installed packages, and search for packages that provide specific files. The information is retrieved directly from the local Pacman database, reflecting the current state of the system's installed software.

This makes it a central command for system administrators and developers alike.

CAVEATS

The `-s` flag searches remote repositories, and may require synchronization first (pacman -Sy). The `-p` flag queries a package file, not the installed database.

USAGE EXAMPLES

List all installed packages:
pacman -Q

Get detailed info about `firefox`:
pacman -Qi firefox

List files installed by `firefox`:
pacman -Ql firefox

Find the package owning `/usr/bin/ls`:
pacman -Qo /usr/bin/ls

List explicitly installed packages:
pacman -Qe

EXIT CODES

Pacman returns 0 if no errors were detected. Return 1 if a query command failed, or a file removal operation failed, or the requested operation is incompatible with the database target. Return 2 if there wasn't enough memory to complete the operation. Return 3 if a database operation failed. Return 4 if a hook failed. Return 127 if pacman-query received an invalid argument.

HISTORY

The `pacman` package manager and, consequently, `pacman-query`, have been integral to Arch Linux since its inception.

It was designed to be simple, lightweight, and efficient. Over time, it has evolved through various versions and gained new features, improving package management capabilities. The query functionality has remained a core part of pacman, essential for users to understand the state of their installed software. Its continued development reflects the community's commitment to a robust and user-friendly package management experience.

Early versions of `pacman-query` focused on basic package information retrieval, while later iterations introduced more advanced features like dependency listing, file ownership lookups, and remote repository searching.

SEE ALSO

pacman(8), pacdiff(1)

Copied to clipboard