dpkg-query
is a command-line tool that is used to query the Debian package database. It provides information about the installed packages, such as their version, status, and dependencies. It can also be used to search for packages that are not currently installed on the system.
Overview
The basic syntax of the dpkg-query
command is as follows:
dpkg-query [options] [package-name-pattern...]
The package-name-pattern
argument is optional. If it is not specified, dpkg-query
will display information about all installed packages. If one or more package names are specified, dpkg-query
will display information about those packages only.
The following are some examples of how to use the dpkg-query
command:
- To display information about all installed packages:
dpkg-query -l
- To display information about a specific package:
dpkg-query -s package-name
- To display the version number of a package:
dpkg-query -W -f='${Version}\n' package-name
- To display the dependencies of a package:
dpkg-query -W -f='${Depends}\n' package-name
- To search for a package that is not currently installed:
dpkg-query -l '*package-name*'
Options
The following table lists the available options for the dpkg-query
command:
Option | Description |
---|---|
-l, –list | Display a list of all installed packages. |
-s, –status package-name | Display the status of the specified package. |
-W, –showformat format | Use the specified format to display package information. |
-f, –showformat format | Use the specified format to display package information. |
-p, –print-avail package-name | Display information about the specified package, including its dependencies. |
-S, –search package-name-pattern | Search for packages that match the specified pattern. |
-i, –info package-name | Display information about the specified package, including its description and maintainer. |
-c, –contents package-name | Display the contents of the specified package. |
-L, –listfiles package-name | Display a list of files installed by the specified package. |
Troubleshooting tips
- If you are getting an error that says “dpkg-query: no packages found matching package-name-pattern”, make sure that you have spelled the package name correctly and that it is installed on your system.
- If you are not getting any output from the
dpkg-query
command, try running it with sudo privileges. Some package information may be restricted to root users only.
Notes
- The
dpkg-query
command is only available on Debian-based Linux distributions, such as Debian, Ubuntu, and Linux Mint. - The
dpkg-query
command is a powerful tool for managing packages on a Linux system. It can be used to search for, install, and remove packages, as well as to display information about installed packages.