← 返回命令列表

Linux command

dpkg-query 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

List

dpkg-query -l

Example

dpkg-query -l '[libc6*]'

Example

dpkg-query -L [libc6]

Example

dpkg-query -s [libc6]

Search

dpkg-query -S [/etc/ld.so.conf.d]

说明

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.

参数

-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

FAQ

What is the dpkg-query command used for?

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.

How do I run a basic dpkg-query example?

Run `dpkg-query -l` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -l, --list _pattern_ do in dpkg-query?

List packages matching pattern