dpkg-query(1)
๐ฆ dpkg-query(1) ๐ฆ
okay bestie, this is the dpkg-query(1) page from the dpkg suite manual โ yes, the whole vibe is โletโs peek inside the dpkg database togetherโ ๐
โจ NAME โจ
dpkg-query โ a tool to query the dpkg database
๐ธ SYNOPSIS ๐ธ
dpkg-query [option...] command
๐ DESCRIPTION ๐
dpkg-query is a tool to show information about packages listed in the dpkg database. Thatโs it, thatโs the whole mission, and itโs lowkey iconic.
๐ COMMANDS ๐
-l,--list [package-name-pattern...]โ List all known packages matching one or more patterns, regardless of their status. This includes any real or virtual package referenced in any dependency relationship field (such asBreaks,Enhances, etc.). If nopackage-name-patternis given, list all packages in/var/lib/dpkg/status, excluding the ones marked as not-installed (i.e. those which have been previously purged). Normal shell wildcard characters are allowed inpackage-name-pattern. Note you will probably have to quotepackage-name-patternto prevent the shell from performing filename expansion. For example this will list all package names starting with โlibc6โ:
dpkg-query -l 'libc6*'
The first three columns of the output show the desired action, the package status, and errors, in that order. โจ
- Desired action:
u= Unknowni= Installh= Holdr= Removep= Purge
- Package status:
n= Not-installedc= Config-filesH= Half-installedU= UnpackedF= Half-configuredW= Triggers-awaitingt= Triggers-pendingi= Installed
- Error flags:
<empty>= (none)R= Reinst-required
An uppercase status or error letter indicates the package is likely to cause severe problems. See dpkg(1) for information about the above states and flags.
The output format of this option is not configurable, but varies automatically to fit the terminal width. It is intended for human readers, and is not easily machine-readable. See -W (--show) and --showformat for a way to configure the output format.
-W,--show [package-name-pattern...]โ Just like the--listoption this will list all packages matching the given patterns. However the output can be customized using the--showformatoption.
The default output format gives one line per matching package, each line consisting of the package name and its installed version, separated by a tab. The package name will be architecture qualified for packages with a Multi-Arch field with the value same or with a foreign architecture, which is an architecture that is neither the native one nor all.
-s,--status [package-name...]โ Report status of specified packages. This just displays the entry in the installed package status database. If nopackage-nameis specified it will display all package entries in the status database (since dpkg 1.19.1). When multiplepackage-nameentries are listed, the requested status entries are separated by an empty line, with the same order as specified on the argument list.-L,--listfiles package-name...โ List files installed to your system frompackage-name. When multiplepackage-names are listed, the requested lists of files are separated by an empty line, with the same order as specified on the argument list.
Each file diversion is printed on its own line after its diverted file, prefixed with one of the following localized strings:
locally diverted to: diverted-to
package diverts others to: diverted-to
diverted by pkg to: diverted-to
Hint: When machine parsing the output, it is customary to set the locale to C.UTF-8 to get reproducible results. On some systems this might also require adapting the LANGUAGE environment variable appropriately if it is already set (see locale(7)).
This command will not list extra files created by maintainer scripts, nor will it list alternatives.
--control-list package-nameโ List control files installed to your system frompackage-name. These can be used as input arguments to--control-show.
Supported since dpkg 1.16.5.
--control-show package-name control-fileโ Print thecontrol-fileinstalled to your system frompackage-nameto the standard output.
Supported since dpkg 1.16.5.
-c,--control-path package-name [control-file]โ List paths for control files installed to your system frompackage-name. Ifcontrol-fileis specified then only list the path for that control file if it is present.
Warning: This command is deprecated as it gives direct access to the internal dpkg database, switch to use--control-listand--control-showinstead for all cases where those commands might give the same end result. Although, as long as there is still at least one case where this command is needed (i.e. when having to remove a damagingpostrmmaintainer script), and while there is no good solution for that, this command will not get removed.
Supported since dpkg 1.15.4.
-S,--search filename-search-pattern...โ Search for packages that own files corresponding to the given patterns. Standard shell wildcard characters can be used in the pattern, where asterisk (*) and question mark (?) will match a slash, and backslash (\) will be used as an escape character.
If the first character in the filename-search-pattern is none of *, [, ?, or / then it will be considered a substring match and will be implicitly surrounded by * (as in *filename-search-pattern*). If the subsequent string contains any of *, [, ?, or \, then it will be handled like a glob pattern; otherwise any trailing / or /. will be removed and a literal path lookup will be performed.
This command will not list extra files created by maintainer scripts, nor will it list alternatives.
The output format consists of one line per matching pattern, with a list of packages owning the pathname separated by a comma (U+002C โ,โ) and a space (U+0020 โ โ), followed by a colon (U+003A โ:โ) and a space, followed by the pathname. As in:
pkgname1, pkgname2: pathname1
pkgname3: pathname2
File diversions are printed with the following localized strings:
diversion by pkgname from: diverted-from
diversion by pkgname to: diverted-to
or for local diversions:
local diversion from: diverted-from
local diversion to: diverted-to
Hint: When machine parsing the output, it is customary to set the locale to C.UTF-8 to get reproducible results.
-p,--print-avail [package-name...]โ Display details about packages, as found in/var/lib/dpkg/available. If nopackage-nameis specified, it will display all package entries in the available database (since dpkg 1.19.1). When multiplepackage-nameare listed, the requested available entries are separated by an empty line, with the same order as specified on the argument list.
Users of APT-based frontends should use apt show package-name instead as the available file is only kept up-to-date when using dselect.
-?,--helpโ Show the usage message and exit.--versionโ Show the version and exit.
โจ OPTIONS โจ
okay bestie, this is the part where dpkg-query gets all its little knobs and dials. every single one is here, no skips ๐
--admindir=dirโ changes where the dpkg database lives. the default location is/var/lib/dpkg.--root=directoryโ sets the root directory to directory, which also sets the administrative directory todirectory/var/lib/dpkg.
supported since dpkg 1.21.0 โจ
--load-availโ also loads the available file when you use the--showand--listcommands, which now default to only querying the status file.
supported since dpkg 1.16.2.
--no-pagerโ disables the use of any pager when showing information.
supported since dpkg 1.19.2.
-f,--showformat=formatโ this one specifies the format of the output that--showwill produce. the format is a string that gets output for each package listed. support for the short option-fhas been around since dpkg 1.13.1 ๐ซถ
in the format string, \ introduces escapes:
\nโ newline\rโ carriage return\tโ tab
a \ before any other character suppresses any special meaning of the following character, which is useful for \ and $.
package information can be included by inserting variable references to package fields using the syntax ${field[;width]}. fields are printed right-aligned unless the width is negative, in which case left alignment is used. the following fields are recognized, but they are not necessarily available in the status file (only internal fields or fields stored in the binary package end up in it):
ArchitectureBugsConffiles(internal)Config-Version(internal)ConflictsBreaksDependsDescriptionDescription-md5(internal, front-end related)EnhancesProtectedEssentialFilename(internal, front-end related)HomepageInstalled-SizeMD5sum(internal, front-end related)MaintainerMulti-ArchOriginPackagePre-DependsPriorityProvidesRecommendsReplacesRevision(obsolete)SectionSHA1(internal, front-end related)SHA256(internal, front-end related)SHA512(internal, front-end related)Size(internal, front-end related)SourceStatus(internal)SuggestsTag(usually not in.debbut in repositoryPackagesfiles)Triggers-Awaited(internal)Triggers-Pending(internal)Version
the following are virtual fields, generated by dpkg-query from values from other fields (note that these do not use valid names for fields in control files):
binary:Packageโ contains the binary package name with a possible architecture qualifier likelibc6:amd64. an architecture qualifier will be present to make the package name unambiguous, for packages with aMulti-Archfield with the valuesameor with a foreign architecture, which is an architecture that is neither the native one norall.
supported since dpkg 1.16.2.
binary:Synopsisโ contains the package short description.
supported since dpkg 1.19.1.
binary:Summaryโ this is an alias forbinary:Synopsis.
supported since dpkg 1.16.2.
db:Status-Abbrevโ contains the abbreviated package status (as three characters), such asiioriHR. see the--listcommand description for more details.
supported since dpkg 1.16.2.
db:Status-Wantโ contains the package wanted status, part of theStatusfield.
supported since dpkg 1.17.11.
db:Status-Statusโ contains the package status word, part of theStatusfield.
supported since dpkg 1.17.11.
db:Status-Eflagโ contains the package status error flag, part of theStatusfield.
supported since dpkg 1.17.11.
db-fsys:Filesโ contains the list of the package filesystem entries separated by newlines.
supported since dpkg 1.19.3.
db-fsys:Last-Modifiedโ contains the timestamp in seconds of the last time the package filesystem entries were modified.
supported since dpkg 1.19.3.
source:Packageโ contains the source package name for this binary package.
supported since dpkg 1.16.2.
source:Versionโ contains the source package version for this binary package.
supported since dpkg 1.16.2.
source:Upstream-Versionโ contains the source package upstream version for this binary package.
supported since dpkg 1.18.16.
the default format string is ${binary:Package}\t${Version}\n. actually, all other fields found in the status file (i.e. user defined fields) can be requested, too. they will be printed as-is, though, no conversion nor error checking is done on them. to get the name of the dpkg maintainer and the installed version, you could run:
dpkg-query -f='${binary:Package} ${Version}\t${Maintainer}\n' \
-W dpkg
๐ EXIT STATUS ๐
0โ the requested query was successfully performed. slay โ1โ the requested query failed either fully or partially, due to no file or package being found. exception:--control-path,--control-list, and--control-showtreat those errors as fatal ๐ญ2โ fatal or unrecoverable error due to invalid command-line usage, or interactions with the system, such as accesses to the database, memory allocations, etc. this is the "bestie what happened" tier ๐
๐ฆ ENVIRONMENT ๐ฆ
External environment
SHELLโ sets the program to execute when spawning a command via a shell.
supported since dpkg 1.19.2.
COLUMNSโ sets the number of columns to expect in the--listoutput, to determine the padding to use, without causing any truncation.
supported since dpkg 1.23.8.
PAGER,DPKG_PAGERโ sets the pager command to use, which will be executed with$SHELL -c. ifSHELLis not set,shwill be used instead.
when non-empty, DPKG_PAGER overrides the PAGER environment variable. if none of the programs pointed by DPKG_PAGER or PAGER are present, the following programs will be tried in order (since dpkg 1.22.12): the default pager more, then less(1), more(1), and finally cat(1).
the cat value is special, and it is equivalent to disabling paging entirely.
support for PAGER since dpkg 1.19.1. support for DPKG_PAGER since dpkg 1.19.2.
DPKG_ROOTโ if set and the--rootoption has not been specified, it will be used as the filesystem root directory.
supported since dpkg 1.21.0.
DPKG_ADMINDIRโ if set and the--admindiroption has not been specified, it will be used as the dpkg data directory.DPKG_DEBUGโ sets the debug mask from an octal value. the currently accepted flags are described in thedpkg --debugoption, but not all these flags might have an effect on this program.
supported since dpkg 1.21.10.
DPKG_COLORSโ sets the color mode. the currently accepted values are:auto(default),always, andnever.
supported since dpkg 1.18.5.
DPKG_NLSโ if set, it will be used to decide whether to activate Native Language Support, also known as internationalization (or i18n) support. the accepted values are:0and1(default).
supported since dpkg 1.22.7.
Internal environment
LESSโ defined by dpkg-query to-FRSXMQ, if not already set, when spawning a pager. to change the default behavior, this variable can be preset to some other value including an empty string, or thePAGERorDPKG_PAGERvariables can be set to disable specific options with-+, for exampleDPKG_PAGER="less -+F".
supported since dpkg 1.19.2.
๐ SECURITY ๐
query operations should never require root, and delegating their execution to unprivileged users via some gain-root command can have security implications (such as privilege escalation), for example when a pager is automatically invoked by the tool. bestie, this is the "do not hand random people the keys" section โ fr fr ๐จ
๐ SEE ALSO ๐
that's the whole dpkg-query(1) saga, bestie โ page version 1.23.11-dirty, dated 2026-09-09. go touch some grass now ๐ฑ๐
๐ฆ where this page comes from
- arch rolling: dpkg 1.23.11-1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms