LinuxCommandLibrary

dpkg-query

query dpkg database information

TLDR

List all installed packages

$ dpkg-query -l
copy
List packages matching pattern
$ dpkg-query -l '[libc6*]'
copy
List files installed by a package
$ dpkg-query -L [libc6]
copy
Show package information
$ dpkg-query -s [libc6]
copy
Search for packages owning files
$ dpkg-query -S [/etc/ld.so.conf.d]
copy

SYNOPSIS

dpkg-query action [options] [pattern|package]

DESCRIPTION

dpkg-query queries the dpkg database for information about installed packages on Debian-based systems. It provides a read-only interface to the package database, allowing you to search for packages, inspect their metadata, and determine file ownership.
The tool is essential for system administration tasks like verifying package installations, troubleshooting file conflicts, and generating package inventories. Unlike dpkg itself, dpkg-query only reads information and never modifies the package database, making it safe to use without elevated privileges.
Its custom output formatting capabilities make it particularly useful in scripts and automation workflows.

PARAMETERS

-l, --list [pattern]

List packages matching pattern
-L, --listfiles package
List files installed by package
-s, --status package
Show package status and information
-S, --search pattern
Find packages owning files matching pattern
-W, --show package
Show package in specified format
-f, --showformat format
Custom output format

CAVEATS

Only queries installed packages, not repositories. Pattern uses shell glob syntax, not regex. Part of dpkg package.

SEE ALSO

dpkg(1), apt-cache(8), dpkg-deb(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community