apk-query(8) System Manager's Manual apk-query(8)

apk query - query information about packages by various criteria

apk query [<options>...] query...

apk query [<options>...] --recursive constraints...

apk query searches for matching packages from selected sources.

In the default mode, query specifiers are interpreted as follows:

name{[<>~=]version}
Select packages by name and optional version match.
text
Select packages by selected fields matching text.

In the --recursive mode, the constraints specify a list of dependencies to satisfy and the solver algorithm is used to determine a list of packages that fullfill these constraints.

The query executes in the following steps:

1.
Each query string is executed independently to select candidate packages
2.
If --all-matches is not specified, the best candidate for given term is added to the list of result packages
3.
The resulting package list is sorted

The applets supporting query specifiers recognize the following options:

--all-matches

Select all matched packages. By default only best match for each query element is selected.

--available

Filter selection to available packages.

--fields FIELDS[:REVERSE_FIELD]

A comma separated list of fields to include in the output. An optional specification to specify the field to output for the synthetic reverse dependency fields can be specifed (name, package or origin).

--format FORMATSPEC

Specify output format from default, yaml or json. The default format is human readable text output.

--from FROMSPEC

Search packages from: system (all system sources), repositories (exclude installed database), installed (exclude normal repositories) or none (commandline repositories only).

--installed

Filter selection to installed packages.

--match FIELDS

A comma separated list of fields to match the query against.

--recursive

Run solver algorithm with given constraints to select packages.

--summarize FIELD[:REVERSE_FIELD]

Produce a summary of the specified field from all matches. Summary is available on the following fields: package, name, origin, depends, provides, replaces, install_if, recommends, reverse-depends, and reverse-install-if.

--upgradable

Filter selection to upgradable packages.

--world

Include apk-world(5) dependencies in constraints. Implies --recursive.

--orphaned

Filter selection to orphaned packages.

The field names are all small letters for --match and --fields options and for the machine parseable output (json and yaml). For the human readable default format the fields are capitalized.

The following package metadata fields are available: name, version, description, arch, license, origin, maintainer, url, commit, build-time, installed-size, file-size, provider-priority, depends, provides, replaces, install-if, layer, tags, triggers, scripts, and replaces-priority. See apk-package(8) package info metadata and package metadata sections for the description of these fields.

Additionally the following fields are available:

contents

File names contained in a package.

download-url

Full URL to download the package from.

owner

Lookup owner package for given path name. (--match only)

package

The package identifier in format name-version (e.g. package-1.0-r0).

repositories

List of repositories the package is available from.

status

Status of an installed package. List of one or more of following keywords:
  • installed
  • broken-files
  • broken-scripts
  • broken-xattr

# search all packages starting with apk
apk query "apk*"

# show owner package of sensors executable in json
apk query --format json --match owner /usr/bin/sensors

# show apk-tools and its dependencies in yaml
apk query --format yaml --recursive apk-tools

# print source packages for all packages providing cmd:apk
apk query --match name,provides cmd:apk --fields origin

# print source packages with specific dependency name
apk query --match dependency so:libapk.so.2.14.9 --fields origin

2025-12-03