{
    "content": [
        {
            "type": "text",
            "text": "# dpkg-query(1) (man)\n\n**Summary:** dpkg-query - a tool to query the dpkg database\n\n**Synopsis:** dpkg-query [option...] command\n\n## Flags\n\n| Flag | Long | Arg | Description |\n|------|------|-----|-------------|\n| — | --load-avail | — | Also load the available file when using the --show and --list commands, which now default to only querying the status fi |\n| — | --no-pager | — | Disables the use of any pager when showing information (since dpkg 1.19.2). |\n| -f | — | — | This option is used to specify the format of the output --show will produce (short option since dpkg 1.13.1). The format |\n\n## See Also\n\n- dpkg(1)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (2 lines)\n- **DESCRIPTION** (2 lines)\n- **COMMANDS** (1 lines) — 8 subsections\n  - -l --list (45 lines)\n  - -W --show (6 lines)\n  - -s --status (6 lines)\n  - -L --listfiles (26 lines)\n  - -c --control-path (11 lines)\n  - -S --search (35 lines)\n  - -p --print-avail (11 lines)\n  - --version (2 lines)\n- **OPTIONS** (7 lines) — 9 subsections\n  - --load-avail (3 lines)\n  - --no-pager (2 lines)\n  - -f --showformat= (20 lines)\n  - Conffiles (internal) (1 lines)\n  - Config-Version (internal) (20 lines)\n  - Revision (obsolete) (3 lines)\n  - Status (internal) (2 lines)\n  - Triggers-Awaited (internal) (1 lines)\n  - Triggers-Pending (internal) (57 lines)\n- **EXIT STATUS** (9 lines)\n- **ENVIRONMENT** (1 lines) — 2 subsections\n  - External environment (21 lines)\n  - Internal environment (6 lines)\n- **SEE ALSO** (5 lines)\n\n## Full Content\n\n### NAME\n\ndpkg-query - a tool to query the dpkg database\n\n### SYNOPSIS\n\ndpkg-query [option...] command\n\n### DESCRIPTION\n\ndpkg-query is a tool to show information about packages listed in the dpkg database.\n\n### COMMANDS\n\n#### -l --list\n\nList all known packages matching one or more patterns, regardless of their status, which\nincludes any real or virtual package referenced in any dependency relationship field\n(such as Breaks, Enhances, etc.).  If no package-name-pattern is given, list all packages\nin /var/lib/dpkg/status, excluding the ones marked as not-installed (i.e.  those which\nhave been previously purged).  Normal shell wildcard characters are allowed in package-\nname-pattern.  Please note you will probably have to quote package-name-pattern to\nprevent the shell from performing filename expansion.  For example this will list all\npackage names starting with “libc6”:\n\ndpkg-query -l 'libc6*'\n\nThe first three columns of the output show the desired action, the package status, and\nerrors, in that order.\n\nDesired action:\n\nu = Unknown\ni = Install\nh = Hold\nr = Remove\np = Purge\n\nPackage status:\n\nn = Not-installed\nc = Config-files\nH = Half-installed\nU = Unpacked\nF = Half-configured\nW = Triggers-awaiting\nt = Triggers-pending\ni = Installed\n\nError flags:\n\n<empty> = (none)\nR = Reinst-required\n\nAn uppercase status or error letter indicates the package is likely to cause severe\nproblems. Please refer to dpkg(1) for information about the above states and flags.\n\nThe output format of this option is not configurable, but varies automatically to fit the\nterminal width. It is intended for human readers, and is not easily machine-readable. See\n-W (--show) and --showformat for a way to configure the output format.\n\n#### -W --show\n\nJust like the --list option this will list all packages matching the given patterns.\nHowever the output can be customized using the --showformat option.  The default output\nformat gives one line per matching package, each line having the name (extended with the\narchitecture qualifier for Multi-Arch same packages) and installed version of the\npackage, separated by a tab.\n\n#### -s --status\n\nReport status of specified packages. This just displays the entry in the installed\npackage status database.  If no package-name is specified it will display all package\nentries in the status database (since dpkg 1.19.1).  When multiple package-name entries\nare listed, the requested status entries are separated by an empty line, with the same\norder as specified on the argument list.\n\n#### -L --listfiles\n\nList files installed to your system from package-name. When multiple package-names are\nlisted, the requested lists of files are separated by an empty line, with the same order\nas specified on the argument list.\n\nEach file diversion is printed on its own line after its diverted file, prefixed with one\nof the following localized strings:\n\n\nlocally diverted to: diverted-to\npackage diverts others to: diverted-to\ndiverted by pkg to: diverted-to\n\nHint: When machine parsing the output, it is customary to set the locale to C.UTF-8 to\nget reproducible results.\n\nThis command will not list extra files created by maintainer scripts, nor will it list\nalternatives.\n\n--control-list package-name\nList control files installed to your system from package-name (since dpkg 1.16.5).  These\ncan be used as input arguments to --control-show.\n\n--control-show package-name control-file\nPrint the control-file installed to your system from package-name to the standard output\n(since dpkg 1.16.5).\n\n#### -c --control-path\n\nList paths for control files installed to your system from package-name (since dpkg\n1.15.4).  If control-file is specified then only list the path for that control file if\nit is present.\n\nWarning: this command is deprecated as it gives direct access to the internal dpkg\ndatabase, please switch to use --control-list and --control-show instead for all cases\nwhere those commands might give the same end result. Although, as long as there is still\nat least one case where this command is needed (i.e. when having to remove a damaging\npostrm maintainer script), and while there is no good solution for that, this command\nwill not get removed.\n\n#### -S --search\n\nSearch for packages that own files corresponding to the given patterns.  Standard shell\nwildcard characters can be used in the pattern, where asterisk (*) and question mark (?)\nwill match a slash, and backslash (\\) will be used as an escape character.\n\nIf the first character in the filename-search-pattern is none of ‘*[?/’ then it will be\nconsidered a substring match and will be implicitly surrounded by ‘*’ (as in *filename-\nsearch-pattern*).  If the subsequent string contains any of ‘*[?\\’, then it will handled\nlike a glob pattern, otherwise any trailing ‘/’ or ‘/.’ will be removed and a literal\npath lookup will be performed.\n\nThis command will not list extra files created by maintainer scripts, nor will it list\nalternatives.\n\nThe output format consists of one line per matching pattern, with a list of packages\nowning the pathname separated by a comma (U+002C ‘,’) and a space (U+0020 ‘ ’), followed\nby a colon (U+003A ‘:’) and a space, followed by the pathname. As in:\n\npkgname1, pkgname2: pathname1\npkgname3: pathname2\n\nFile diversions are printed with the following localized strings:\n\n\ndiversion by pkgname from: diverted-from\ndiversion by pkgname to: diverted-to\n\nor for local diversions:\n\n\nlocal diversion from: diverted-from\nlocal diversion to: diverted-to\n\nHint: When machine parsing the output, it is customary to set the locale to C.UTF-8 to\nget reproducible results.\n\n#### -p --print-avail\n\nDisplay details about packages, as found in /var/lib/dpkg/available.  If no package-name\nis specified, it will display all package entries in the available database (since dpkg\n1.19.1).  When multiple package-name are listed, the requested available entries are\nseparated by an empty line, with the same order as specified on the argument list.\n\nUsers of APT-based frontends should use apt show package-name instead as the available\nfile is only kept up-to-date when using dselect.\n\n-?, --help\nShow the usage message and exit.\n\n#### --version\n\nShow the version and exit.\n\n### OPTIONS\n\n--admindir=dir\nChange the location of the dpkg database. The default location is /var/lib/dpkg.\n\n--root=directory\nSet the root directory to directory, which sets the administrative directory to\n«directory/var/lib/dpkg» (since dpkg 1.21.0).\n\n#### --load-avail\n\nAlso load the available file when using the --show and --list commands, which now default\nto only querying the status file (since dpkg 1.16.2).\n\n#### --no-pager\n\nDisables the use of any pager when showing information (since dpkg 1.19.2).\n\n#### -f --showformat=\n\nThis option is used to specify the format of the output --show will produce (short option\nsince dpkg 1.13.1).  The format is a string that will be output for each package listed.\n\nIn the format string, “\\” introduces escapes:\n\n\\n newline\n\\r carriage return\n\\t tab\n\n“\\” before any other character suppresses any special meaning of the following character,\nwhich is useful for “\\” and “$”.\n\nPackage information can be included by inserting variable references to package fields\nusing the syntax “${field[;width]}”. Fields are printed right-aligned unless the width is\nnegative in which case left alignment will be used. The following fields are recognized\nbut they are not necessarily available in the status file (only internal fields or fields\nstored in the binary package end up in it):\n\nArchitecture\nBugs\n\n#### Conffiles (internal)\n\n#### Config-Version (internal)\n\nConflicts\nBreaks\nDepends\nDescription\nEnhances\nProtected\nEssential\nFilename (internal, front-end related)\nHomepage\nInstalled-Size\nMD5sum (internal, front-end related)\nMSDOS-Filename (internal, front-end related)\nMaintainer\nOrigin\nPackage\nPre-Depends\nPriority\nProvides\nRecommends\nReplaces\n\n#### Revision (obsolete)\n\nSection\nSize (internal, front-end related)\nSource\n\n#### Status (internal)\n\nSuggests\nTag (usually not in .deb but in repository Packages files)\n\n#### Triggers-Awaited (internal)\n\n#### Triggers-Pending (internal)\n\nVersion\n\nThe following are virtual fields, generated by dpkg-query from values from other fields\n(note that these do not use valid names for fields in control files):\n\nbinary:Package\nIt contains the binary package name with a possible architecture qualifier like\n“libc6:amd64” (since dpkg 1.16.2).  An architecture qualifier will be present to make\nthe package name unambiguous, for example if the package has a Multi-Arch field with\na value of same or the package is of a foreign architecture.\n\nbinary:Synopsis\nIt contains the package short description (since dpkg 1.19.1).\n\nbinary:Summary\nThis is an alias for binary:Synopsis (since dpkg 1.16.2).\n\ndb:Status-Abbrev\nIt contains the abbreviated package status (as three characters), such as “ii ” or\n“iHR” (since dpkg 1.16.2).  See the --list command description for more details.\n\ndb:Status-Want\nIt contains the package wanted status, part of the Status field (since dpkg 1.17.11).\n\ndb:Status-Status\nIt contains the package status word, part of the Status field (since dpkg 1.17.11).\n\ndb:Status-Eflag\nIt contains the package status error flag, part of the Status field (since dpkg\n1.17.11).\n\ndb-fsys:Files\nIt contains the list of the package filesystem entries separated by newlines (since\ndpkg 1.19.3).\n\ndb-fsys:Last-Modified\nIt contains the timestamp in seconds of the last time the package filesystem entries\nwere modified (since dpkg 1.19.3).\n\nsource:Package\nIt contains the source package name for this binary package (since dpkg 1.16.2).\n\nsource:Version\nIt contains the source package version for this binary package (since dpkg 1.16.2)\n\nsource:Upstream-Version\nIt contains the source package upstream version for this binary package (since dpkg\n1.18.16)\n\nThe default format string is “${binary:Package}\\t${Version}\\n”.  Actually, all other\nfields found in the status file (i.e. user defined fields) can be requested, too. They\nwill be printed as-is, though, no conversion nor error checking is done on them. To get\nthe name of the dpkg maintainer and the installed version, you could run:\n\ndpkg-query -f='${binary:Package} ${Version}\\t${Maintainer}\\n' \\\n-W dpkg\n\n### EXIT STATUS\n\n0   The requested query was successfully performed.\n\n1   The requested query failed either fully or partially, due to no file or package being\nfound (except for --control-path, --control-list and --control-show were such errors are\nfatal).\n\n2   Fatal or unrecoverable error due to invalid command-line usage, or interactions with the\nsystem, such as accesses to the database, memory allocations, etc.\n\n### ENVIRONMENT\n\n#### External environment\n\nSHELL\nSets the program to execute when spawning a command via a shell (since dpkg 1.19.2).\n\nPAGER\nDPKGPAGER\nSets the pager command to use (since dpkg 1.19.1), which will be executed with «$SHELL\n-c».  If SHELL is not set, «sh» will be used instead.  The DPKGPAGER overrides the PAGER\nenvironment variable (since dpkg 1.19.2).\n\nDPKGROOT\nIf set and the --root option has not been specified, it will be used as the filesystem\nroot directory (since dpkg 1.21.0).\n\nDPKGADMINDIR\nIf set and the --admindir option has not been specified, it will be used as the dpkg data\ndirectory.\n\nDPKGCOLORS\nSets the color mode (since dpkg 1.18.5).  The currently accepted values are: auto\n(default), always and never.\n\n#### Internal environment\n\nLESS\nDefined by dpkg-query to “-FRSXMQ”, if not already set, when spawning a pager (since dpkg\n1.19.2).  To change the default behavior, this variable can be preset to some other value\nincluding an empty string, or the PAGER or DPKGPAGER variables can be set to disable\nspecific options with «-+», for example DPKGPAGER=\"less -+F\".\n\n### SEE ALSO\n\ndpkg(1).\n\n\n\n1.21.1                                       2025-09-09                                dpkg-query(1)\n\n"
        }
    ],
    "structuredContent": {
        "command": "dpkg-query",
        "section": "1",
        "mode": "man",
        "summary": "dpkg-query - a tool to query the dpkg database",
        "synopsis": "dpkg-query [option...] command",
        "flags": [
            {
                "flag": "",
                "long": "--load-avail",
                "arg": null,
                "description": "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)."
            },
            {
                "flag": "",
                "long": "--no-pager",
                "arg": null,
                "description": "Disables the use of any pager when showing information (since dpkg 1.19.2)."
            },
            {
                "flag": "-f",
                "long": null,
                "arg": null,
                "description": "This option is used to specify the format of the output --show will produce (short option since dpkg 1.13.1). The format is a string that will be output for each 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 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): Architecture Bugs"
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "dpkg",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/dpkg/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COMMANDS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-l --list",
                        "lines": 45,
                        "flag": "-l",
                        "long": "--list"
                    },
                    {
                        "name": "-W --show",
                        "lines": 6,
                        "flag": "-W",
                        "long": "--show"
                    },
                    {
                        "name": "-s --status",
                        "lines": 6,
                        "flag": "-s",
                        "long": "--status"
                    },
                    {
                        "name": "-L --listfiles",
                        "lines": 26,
                        "flag": "-L",
                        "long": "--listfiles"
                    },
                    {
                        "name": "-c --control-path",
                        "lines": 11,
                        "flag": "-c",
                        "long": "--control-path"
                    },
                    {
                        "name": "-S --search",
                        "lines": 35,
                        "flag": "-S",
                        "long": "--search"
                    },
                    {
                        "name": "-p --print-avail",
                        "lines": 11,
                        "flag": "-p",
                        "long": "--print-avail"
                    },
                    {
                        "name": "--version",
                        "lines": 2,
                        "long": "--version"
                    }
                ]
            },
            {
                "name": "OPTIONS",
                "lines": 7,
                "subsections": [
                    {
                        "name": "--load-avail",
                        "lines": 3,
                        "long": "--load-avail"
                    },
                    {
                        "name": "--no-pager",
                        "lines": 2,
                        "long": "--no-pager"
                    },
                    {
                        "name": "-f --showformat=",
                        "lines": 20,
                        "flag": "-f"
                    },
                    {
                        "name": "Conffiles (internal)",
                        "lines": 1
                    },
                    {
                        "name": "Config-Version (internal)",
                        "lines": 20
                    },
                    {
                        "name": "Revision (obsolete)",
                        "lines": 3
                    },
                    {
                        "name": "Status (internal)",
                        "lines": 2
                    },
                    {
                        "name": "Triggers-Awaited (internal)",
                        "lines": 1
                    },
                    {
                        "name": "Triggers-Pending (internal)",
                        "lines": 57
                    }
                ]
            },
            {
                "name": "EXIT STATUS",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "ENVIRONMENT",
                "lines": 1,
                "subsections": [
                    {
                        "name": "External environment",
                        "lines": 21
                    },
                    {
                        "name": "Internal environment",
                        "lines": 6
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ]
    }
}