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 usingany.?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 haveEssential: yesset 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 version2.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 aftera=inapt-cache policy.?codename(REGEX)โ selects versions that come from the codename that matches the specified regular expression. Codename, here, means the values aftern=inapt-cache policy.?installed,~iโ selects package versions that are currently installed. Versions prior to2.5.4only matched at the package level, hence?any-version(?installed?version(2.0))matchedeven if2.0was 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 aftero=inapt-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 thePrioritystring 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?dependsand 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
?narrowaccepts infinite argumentsfoocannot 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 containpoptional. one lil character, whole different meaning ๐ญ- Dependency types for
~Dand related operators need to be specified in the canonical case.
๐ SEE ALSO ๐
๐ 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 ๐
- 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
- arch rolling: apt 3.3.5-1 ยท BSD-3-Clause AND GPL-2.0-only AND GPL-2.0-or-later AND MIT
- nixpkgs unstable: apt 3.3.5
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms