Section: APT (7)
Updated: 27 December 2020
apt-patterns - Syntax and semantics of apt search patterns
Starting with version 2.0,
provides support for patterns, which can be used to query the apt cache for packages.
These patterns provide the basic means to combine other patterns into more complex expressions, as well as
?and(PATTERN, PATTERN, ...), PATTERN PATTERN ...
Selects objects where all specified patterns match.
Selects objects where PATTERN does not match.
?or(PATTERN, PATTERN, ...), PATTERN | PATTERN | ...
Selects objects where at least one of the specified patterns match.
Selects all objects.
Selects the same as
PATTERN, can be used to work around precedence, for example,
Selects packages where all versions match PATTERN. When matching versions instead, same as PATTERN.
Selects any version where the pattern matches on the version.
For example, while
matches a package which has one version containing 1 and one version containing 2,
to act on the same version.
Selects any version matching all PATTERNs, short for
These patterns select specific packages.
Selects packages matching the specified architecture, which may contain wildcards using any.
Selects packages that were installed automatically.
Selects packages that have broken dependencies.
Selects packages that are not fully installed, but have solely residual configuration files left.
Selects packages that have Essential: yes set in their control file.
Selects packages with the exact specified name.
Selects packages that can be removed automatically.
Selects packages that are currently installed.
Selects packages where the name matches the given regular expression.
Selects packages that no longer exist in repositories.
Selects packages that can be upgraded (have a newer candidate).
Selects all virtual packages; that is packages without a version. These exist when they are referenced somewhere in the archive, for example because something depends on that name.
These patterns select specific versions of a package.
Selects versions that come from the archive that matches the specified regular expression. Archive, here, means the values after
Selects versions that come from the origin that matches the specified regular expression. Origin, here, means the values after
Selects versions where the section matches the specified regular expression.
Selects versions where the source package name matches the specified regular expression.
Selects versions where the source package version matches the specified regular expression.
Selects versions where the version string matches the specified regular expression.
PACKAGE RELATIONSHIP PATTERNS
These patterns match specific package versions that depend/conflict with some other packages.
?depends(PATTERN), ~DPATTERN, ?pre-depends(PATTERN), ~DPre-Depends:PATTERN, ?suggests(PATTERN), ~DSuggests:PATTERN, ?conflicts(PATTERN), ~DConflicts:PATTERN, ?replaces(PATTERN), ~DReplaces:PATTERN, ?obsoletes(PATTERN), ~DObsoletes:PATTERN, ?breaks(PATTERN), ~DBreaks:PATTERN, ?enhances(PATTERN), ~DEnhances:PATTERN
Selects versions depending/pre-depending/suggesting/conflicting/etc on/with/ packages matching PATTERN.
and friends - selects all packages that have reverse-dependencies (versions) matching PATTERN.
is one of the dependency types such as
depends, so that we don't have to repeat the entire list from the first paragraph here.
apt remove ?garbage
Remove all packages that are automatically installed and no longer needed - same as apt autoremove
apt purge ?config-files
Purge all packages that only have configuration files left
apt list '~i !~M (~slibs|~sperl|~spython)'
List all manually-installed packages in sections matching libs, perl, or python.
MIGRATING FROM APTITUDE
Patterns in apt are heavily inspired by patterns in aptitude, but with some tweaks:
Syntax is uniform: If there is an opening parenthesis after a term, it is always assumed to be the beginning of an argument list.
In aptitude, a syntactic form
if foo does not take an argument. In APT, this will cause an error.
Not all patterns are supported.
Some additional patterns are available, for example, for finding gstreamer codecs.
Escaping terms with
is not supported.
A trailing comma is allowed in argument lists
?narrow accepts infinite arguments
cannot be used as a shortform for
?name(foo), as this can cause typos to go unnoticed: Consider
?and(...,~poptional): this requires the package to have
priority, but if you do not type the
~, it would require the package name to contain
Grouping patterns with
are not supported. We do not believe that the use of
is that common, and the grouping is not necessary without it.
Dependency types for ~D and related operators need to be specified in the canonical case.
m[blue]APT bug pagem. If you wish to report a bug in APT, please see
APT was written by the APT team
APT bug page