expac
Query and extract package information from pacman
TLDR
List the dependencies of a package
List the optional dependencies of a package
List the download size of packages in MiB
List packages marked for upgrade with their download size
List explicitly-installed packages with their optional dependencies
SYNOPSIS
expac [options] <format string> [package-names...]
PARAMETERS
-Q
Query the local (installed) package database.
-S
Query the sync (repository) package database.
-L
List all available format fields with their descriptions. Useful for constructing custom format strings.
-q
Suppress warnings and errors. Only output requested data.
-H
Print a header row before the formatted output, indicating the fields.
-v
Enable verbose output, showing more details about the query process.
-V
Print the version information for expac.
--cached
Query packages in the pacman cache directory. Requires package names.
--foreign
Limit query to 'foreign' packages (packages not found in any configured sync database, typically AUR packages).
--ignored
Limit query to packages that are currently ignored by pacman.
--uninstalled
Limit query to packages that are NOT currently installed.
--groups
Query package groups instead of individual packages.
--depends <package>
List packages that depend on the specified package.
--requiredby <package>
List packages that are required by the specified package.
--search <regex>
Search package names and descriptions using the provided regular expression.
--regex
Treat subsequent package names as regular expressions for matching.
--separator <string>
Use the specified string as a field separator for list-type fields (e.g., dependencies).
--format <string>
Specify the format string using this option instead of as a positional argument. Useful for complex strings.
--pager
Pipe the output through a pager (e.g., 'less') for easier viewing of long results.
--color
Enable color output for fields where applicable.
DESCRIPTION
expac is a powerful and flexible command-line utility designed for querying and displaying information about packages in Arch Linux. Built upon libalpm, the core library of pacman, it provides a highly customizable way to retrieve package details from both the local package database and synced repositories.
Unlike pacman -Qi or pacman -Ss which offer fixed output formats, expac allows users to define arbitrary output formats using printf-like format strings, enabling precise control over the displayed data. This makes it invaluable for scripting, custom package listings, and quick lookups, providing access to a vast array of package attributes such as name, version, architecture, description, install date, size, dependencies, required-by packages, conflicts, provides, and much more. It supports various query modes, including installed packages, repository packages, foreign packages, and specific database lookups.
CAVEATS
expac is primarily an Arch Linux specific utility and relies on the libalpm library and pacman package databases. It is not available by default on other Linux distributions. The power of its custom format strings also implies a learning curve to master the various field specifiers and modifiers. Complex queries or those involving large datasets might have noticeable performance implications.
FORMAT STRING SYNTAX
The core strength of expac lies in its printf-like format strings. These strings define how package information is presented. Fields are specified using a percent sign followed by a character (e.g., %n for package name, %v for version, %d for description). Many fields support modifiers for different output formats; for example, %S for human-readable size or %t for formatted time. To discover all available fields and their modifiers, use the expac -L command.
FIELD TYPES AND MODIFIERS
expac supports various field types including strings, numbers, booleans, and lists. It automatically handles type conversions and formatting based on the field type and any provided modifiers. For instance, a list of dependencies might be separated by a default comma, but can be customized using the --separator option. Boolean fields can be formatted to display 'yes'/'no' or other custom strings.
HISTORY
expac was developed as a more flexible and powerful alternative to pacman's built-in query capabilities within the Arch Linux ecosystem. Its genesis was driven by the need for fine-grained control over package information output, which was lacking in the standard pacman -Qi or pacman -Ss commands. Leveraging libalpm, the same underlying library used by pacman itself, expac ensures seamless integration and consistency with Arch's official package management system. It has become a staple utility for Arch Linux users and script developers who require highly customized package data for system reporting, automation, and advanced package introspection.
SEE ALSO
pacman(8), alpm-query(8), pacinfo(1)