Linux "dpkg-query" Command Line Options and Examples
a tool to query the dpkg database

dpkg-query is a tool to show information about packages listed in the dpkg database.COMMANDS -l, --list [package-name-pattern..


dpkg-query [option...] command

Command Line Options:

Change the location of the dpkg database. The default location is /var/lib/dpkg.
dpkg-query --admindir ...
Also load the available file when using the --show and --list commands, which now default to only querying the status file(since dpkg 1.16.2).
dpkg-query --load-avail ...
This option is used to specify the format of the output --show will produce. The format is a string that will be output foreach package listed.In the format string, “\” introduces escapes:\n newline\r carriage return\t tab“\” 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 will be used. The following fieldsare recognized but they are not necessarily available in the status file (only internal fields or fields stored in the binarypackage end up in it):ArchitectureBugsConffiles (internal)Config-Version (internal)ConflictsBreaksDependsDescriptionEnhancesEssentialFilename (internal, front-end related)HomepageInstalled-SizeMD5sum (internal, front-end related)MSDOS-Filename (internal, front-end related)MaintainerOriginPackagePre-DependsPriorityProvidesRecommendsReplacesRevision (obsolete)SectionSize (internal, front-end related)SourceStatus (internal)SuggestsTag (usually not in .deb but in repository Packages files)Triggers-Awaited (internal)Triggers-Pending (internal)VersionThe following are virtual fields, generated by dpkg-query from values from other fields (note that these do not use validnames for fields in control files):binary:PackageIt contains the binary package name with a possible architecture qualifier like “libc6:amd64” (since dpkg 1.16.2). Anarchitecture qualifier will be present to make the package name unambiguous, for example if the package has aMulti-Arch field with a value of same or the package is of a foreign architecture.binary:SummaryIt contains the package short description (since dpkg 1.16.2).db:Status-AbbrevIt contains the abbreviated package status (as three characters), such as “ii ” or “iHR” (since dpkg 1.16.2). See the
dpkg-query -f ...
db:Status-WantIt contains the package wanted status, part of the Status field (since dpkg 1.17.11).db:Status-StatusIt contains the package status word, part of the Status field (since dpkg 1.17.11).db:Status-EflagIt contains the package status error flag, part of the Status field (since dpkg 1.17.11).source:PackageIt contains the source package name for this binary package (since dpkg 1.16.2).source:VersionIt contains the source package version for this binary package (since dpkg 1.16.2)source:Upstream-VersionIt contains the source package upstream version for this binary package (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 onthem. To get the name of the dpkg maintainer and the installed version, you could run:dpkg-query -W -f='${binary:Package} ${Version}\t${Maintainer}\n' dpkgEXIT STATUS0 The requested query was successfully performed.1 The requested query failed either fully or partially, due to no file or package being found (except for --control-path,
dpkg-query --list ...
2 Fatal or unrecoverable error due to invalid command-line usage, or interactions with the system, such as accesses to thedatabase, memory allocations, etc.ENVIRONMENTDPKG_ADMINDIRIf set and the --admindir option has not been specified, it will be used as the dpkg data directory.COLUMNSThis setting influences the output of the --list option by changing the width of its output.
dpkg-query --control-list ...