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
| Name | Type | Description |
|---|---|---|
| -W | option | Show package information for matching patterns; no pattern selects package records without a name filter (not necessarily installed). |
| -f | option | Takes an output template such as ${Package} followed by a newline. |
| PATTERN | operand | Optional 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