commands

dpkg-query — query installed Debian packages

Queries installed package database. -W with format fields is useful for inventory; -S searches recorded file paths, which may differ from resolved symlinks. Use the specified distribution and fresh private workspace; no sudo.

Formal Syntax & Structure

linux syntaxlinux
dpkg-query -W [-f FORMAT] [PATTERN...]

Parameters & Attributes

NameTypeDescription
-WoptionShow package information for matching patterns; no pattern selects package records without a name filter (not necessarily installed).
-foptionTakes an output template such as ${Package} followed by a newline.
PATTERNoperandOptional package name or matching pattern; quote wildcards to prevent shell expansion.

Return Value

exit status and output

Queries installed package database. -W with format fields is useful for inventory; -S searches recorded file paths, which may differ from resolved symlinks.

Working Example

Example Snippetlinux
dpkg-query -W -f='${Package}\n' bash
Linux Reference