APT-PATTERNS(7)

๐Ÿ’ซ apt-patterns(7) โ€” the APT patterns page, bestie edition ๐Ÿ’ซ

okay so this is the manual page for apt-patterns from the APT fam, section 7 of the manual. Sit down, grab a lil snack ๐Ÿ“, and let's get into it.

โœจ NAME โœจ

apt-patterns โ€” the syntax and semantics of apt search patterns. yes that's the whole name section, she's brief and she's iconic ๐Ÿ’…

๐ŸŒธ DESCRIPTION ๐ŸŒธ

Starting with version 2.0, APT provides support for patterns, which can be used to query the apt cache for packages. that's it, that's the vibe. patterns = the way you ask the cache "hey bestie, show me the packages that match this" ๐Ÿฆ‹


๐Ÿง  LOGIC PATTERNS ๐Ÿง 

These patterns provide the basic means to combine other patterns into more complex expressions, as well as ?true and ?false patterns. think of them as the glue, the group-chat admins of the pattern world ๐Ÿ‘‘

  • ?and(PATTERN, PATTERN, ...), PATTERN PATTERN ... โ€” selects objects where all specified patterns match. everyone has to agree, no exceptions, periodt.
  • ?false, ~F โ€” selects nothing. literally nothing. empty. void. ghosted ๐Ÿ’€
  • ?not(PATTERN), !PATTERN โ€” selects objects where PATTERN does not match. the hater of the group.
  • ?or(PATTERN, PATTERN, ...), PATTERN | PATTERN | ... โ€” selects objects where at least one of the specified patterns match. pick-me energy, but make it useful ๐Ÿซถ
  • ?true, ~T โ€” selects all objects. everybody. the whole party.
  • (PATTERN) โ€” selects the same as PATTERN, and can be used to work around precedence, for example, (~ramd64|~ri386)~nfoo. parentheses are the "no bestie, group these first" of the whole thing.

๐Ÿ” NARROWING PATTERNS ๐Ÿ”

  • ?all-versions(PATTERN) โ€” selects packages where all versions match PATTERN. When matching versions instead, same as PATTERN.
  • ?any-version(PATTERN) โ€” selects any version where the pattern matches on the version.

For example, while ?and(?version(1),?version(2)) matches a package which has one version containing 1 and one version containing 2, ?any-version(?and(?version(1),?version(2))) restricts the ?and to act on the same version. yeah. same version. not "one here and one there" ๐ŸŽฏ

  • ?narrow(PATTERN...) โ€” selects any version matching all *PATTERN*s, short for ?any-version(?and(PATTERN...)).

๐Ÿ“ฆ PACKAGE PATTERNS ๐Ÿ“ฆ

These patterns select specific packages.

  • ?architecture(WILDCARD), ~rWILDCARD โ€” selects packages matching the specified architecture, which may contain wildcards using any.
  • ?automatic, ~M โ€” selects packages that were installed automatically. the "i didn't ask for this but ok" packages.
  • ?broken, ~b โ€” selects packages that have broken dependencies. ๐Ÿ’€ it's giving chaos.
  • ?config-files, ~c โ€” selects packages that are not fully installed, but have solely residual configuration files left. just the crumbs, basically ๐Ÿž
  • ?essential, ~E โ€” selects packages that have Essential: yes set in their control file.
  • ?exact-name(NAME) โ€” selects packages with the exact specified name. no fuzzy matching, no vibes, exact.
  • ?garbage, ~g โ€” selects packages that can be removed automatically. trash day ๐Ÿ—‘๏ธโœจ
  • ?installed, ~i โ€” selects packages that are currently installed. Since version 2.5.4, narrowing this pattern (see narrowing patterns above) makes it only match installed versions (see version patterns below).
  • ?name(REGEX), ~nREGEX โ€” selects packages where the name matches the given regular expression.
  • ?obsolete, ~o โ€” selects packages that no longer exist in repositories. gone, reduced to atoms.
  • ?phasing โ€” selects packages that will be kept back in upgrades due to phasing.
  • ?upgradable, ~U โ€” selects packages that can be upgraded (have a newer candidate). glow-up available ๐Ÿ’…
  • ?virtual, ~v โ€” 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.

๐ŸŽ€ VERSION PATTERNS ๐ŸŽ€

These patterns select specific versions of a package.

  • ?archive(REGEX), ~AREGEX โ€” selects versions that come from the archive that matches the specified regular expression. Archive, here, means the values after a= in apt-cache policy.
  • ?codename(REGEX) โ€” selects versions that come from the codename that matches the specified regular expression. Codename, here, means the values after n= in apt-cache policy.
  • ?installed, ~i โ€” selects package versions that are currently installed. Versions prior to 2.5.4 only matched at the package level, hence ?any-version(?installed?version(2.0))matched even if 2.0 was not installed, but another version was.
ngl that legacy behaviour is a lil cursed, but it's documented so we move ๐Ÿ™ˆ (and yes, that line is written exactly like that in the original โ€” the missing space is canon now)
  • ?origin(REGEX), ~OREGEX โ€” selects versions that come from the origin that matches the specified regular expression. Origin, here, means the values after o= in apt-cache policy.
  • ?section(REGEX), ~sREGEX โ€” selects versions where the section matches the specified regular expression.
  • ?source-package(REGEX), ~eREGEX โ€” selects versions where the source package name matches the specified regular expression.
  • ?source-version(REGEX) โ€” selects versions where the source package version matches the specified regular expression.
  • ?version(REGEX), ~VREGEX โ€” selects versions where the version string matches the specified regular expression.
  • ?priority(NAME), ~pNAME โ€” selects versions where the Priority string equals the given name.
  • ?security โ€” selects packages that are a security update or succeed a security update. ๐Ÿ›ก๏ธ slaying, safely.

๐Ÿ”— PACKAGE RELATIONSHIP PATTERNS ๐Ÿ”—

These patterns match specific package versions that depend/conflict with some other packages.

  • ?depends(PATTERN), ~DPATTERN, ?predepends(PATTERN), ~DPreDepends:PATTERN, ?suggests(PATTERN), ~DSuggests:PATTERN, ?recommends(PATTERN), ~DRecommends: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/recommending/conflicting/etc on/with/ packages matching PATTERN.
  • ?reverse-depType(PATTERN), ~RDepType:PATTERN โ€” opposite of ?depends and friends โ€” selects all packages that have reverse-dependencies (versions) matching PATTERN.

depType 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. you're welcome, our fingers were tired ๐Ÿ˜ฎโ€๐Ÿ’จ

๐ŸŒˆ EXAMPLES ๐ŸŒˆ

apt remove ?garbage

Remove all packages that are automatically installed and no longer needed โ€” same as apt autoremove. spring cleaning, but make it command line ๐Ÿงนโœจ

apt purge ?config-files

Purge all packages that only have configuration files left. bye bye leftover crumbs ๐Ÿช๐Ÿ‘‹

apt list '~i !~M (~slibs|~sperl|~spython)'

List all manually-installed packages in sections matching libs, perl, or python. a highly curated little list, we love to see it ๐Ÿ’…


๐Ÿงš 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 "?foo(bar)" could mean "?and(?foo,bar)" if foo does not take an argument. In APT, this will cause an error. no guessing games, bestie ๐Ÿšซ

  • 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
  • foo 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 required priority, but if you do not type the ~, it would require the package name to contain poptional. one lil character, whole different meaning ๐Ÿ˜ญ
  • Dependency types for ~D and related operators need to be specified in the canonical case.

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

apt-get(8), apt(8)

๐Ÿ› BUGS ๐Ÿ›

APT bug page[1]. If you wish to report a bug in APT, please see /usr/share/doc/debian/bug-reporting.txt or the reportbug(1) command.

โœ๏ธ AUTHOR โœ๏ธ

APT was written by the APT team <apt@packages.debian.org>.

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

Jason Gunthorpe

APT team

๐Ÿ“ NOTES ๐Ÿ“

  1. APT bug page https://bugs.debian.org/src:apt

and that's the whole page, bestie ๐Ÿซถ this was APT 3.3.5, dated 07 April 2026, living its best life in section 7 of the manual โ€” go forth and pattern-match, you're gonna slay โญ๐Ÿ’–

๐Ÿ“ฆ where this page comes from