LinuxCommandLibrary

expac

Query and extract package information from pacman

TLDR

List the dependencies of a package

$ expac [[-S|--sync]] '%D' [package]
copy

List the optional dependencies of a package
$ expac [[-S|--sync]] "%o" [package]
copy

List the download size of packages in MiB
$ expac [[-S|--sync]] [[-H|--humansize]] M '%k\t%n' [package1 package2 ...]
copy

List packages marked for upgrade with their download size
$ expac [[-S|--sync]] [[-H|--humansize]] M '%k\t%n' $(pacman -Qqu) | sort [[-sh|--sort --human-numeric-sort]]
copy

List explicitly-installed packages with their optional dependencies
$ expac [[-d|--delim]] '\n\n' [[-l|--listdelim]] '\n\t' [[-Q|--query]] '%n\n\t%O' $(pacman -Qeq)
copy

SYNOPSIS

expac [options] [FORMAT]

PARAMETERS

-b, --brief
    Suppress headers and footers for clean output.

-G
    Query sync database package groups.

-H
    Query the local package file repository.

-m NUM, --max=NUM
    Limit results to at most NUM packages.

-Q, --qinstalled
    Query locally installed packages.

-S
    Query sync (remote) databases (default).

-h, --help
    Display usage help.

-V, --version
    Print version information.

DESCRIPTION

expac is a lightweight C tool for querying Arch Linux package databases via libalpm. It extracts package metadata and formats output using printf(1)-style strings, enabling custom reports on names, sizes, versions, dependencies, and more.

Default behavior queries sync repositories for available packages. Use -Q for installed packages, -G for groups, or -H for the local file repository. Examples: expac '%m %n' lists install sizes and names; expac -Q -m10 '%m %n' shows the 10 largest installed packages.

Ideal for scripting, disk usage analysis, dependency audits, and generating package lists. Faster than pacman -Qi for bulk queries, with no forking. Supports sorting via pipes to sort(1). Essential for Arch users managing systems or creating custom tools.

CAVEATS

Arch Linux/pacman-specific; requires libalpm. Invalid FORMAT specifiers cause errors. Large queries without -m may produce excessive output or high memory use.

KEY FORMAT SPECIFIERS

%n: name
%V: version
%D: description
%m: disk size (human)
%d: download size
%U: URL
%c: dependencies
%p: provides
%g: group. See man expac for full list with modifiers.

HISTORY

Developed by Andreas Henriksson in 2010; initially AUR, now in Arch extra repository. Uses libalpm for efficient access; actively maintained for pacman compatibility.

SEE ALSO

pacman(8), pacsearch(1), pkgfile(1), alpm-json(1)

Copied to clipboard