Using the xbps-query command (with examples)
Introduction
The xbps-query command is a utility that allows you to query package and repository information in XBPS, the package manager used by Void Linux. In this article, we will explore different use cases of the xbps-query command with examples to demonstrate how it can be utilized effectively.
1: Searching for a package in remote repositories
Code:
xbps-query --search regular_expression|keyword --repository --regex
Motivation: When you are looking for a specific package in the remote repositories, the xbps-query command can help you quickly search for it based on a regular expression or keyword.
Explanation:
--search
: Specifies the search mode.regular_expression|keyword
: The regular expression or keyword used for searching.--repository
: Limits the search to remote repositories.--regex
: Forces the search to use regular expressions.
Example Output:
libxml2-devel-2.9.12_2 XML parsing library, development version
libxml2-doc-2.9.12_2 XML parsing library, documentation
2: Showing information about an installed package
Code:
xbps-query --show package
Motivation: When you have an installed package and need detailed information about it, such as version, package description, dependencies, and installed files, the xbps-query command can provide that information.
Explanation:
--show
: Specifies the show mode.package
: The name of the installed package.
Example Output:
pkgname: libxml2
version: 2.9.12_2
architecture: x86_64-musl
maintainer: John Doe <john@doe.com>
...
3: Showing information about a package in remote repositories
Code:
xbps-query --show package --repository
Motivation: If you are interested in a package available in the remote repositories but not yet installed on your system, the xbps-query command can display information about the package before deciding to install it.
Explanation:
--repository
: Limits the show operation to remote repositories.
Example Output:
pkgname: libxml2-devel
version: 2.9.12_2
architecture: x86_64-musl
maintainer: Jane Smith <jane@smith.com>
...
4: Listing packages registered in the package database
Code:
xbps-query --list-pkgs
Motivation: To get an overview of all packages installed in your system, the xbps-query command can list all the packages registered in the package database.
Explanation:
--list-pkgs
: Specifies the list-pkgs mode.
Example Output:
libxml2-2.9.12_2
libxml2-devel-2.9.12_2
libxml2-doc-2.9.12_2
...
5: Listing explicitly installed packages
Code:
xbps-query --list-manual-pkgs
Motivation: To see the packages that were explicitly installed and are not automatically installed as dependencies, the xbps-query command can list the manually installed packages.
Explanation:
--list-manual-pkgs
: Specifies the list-manual-pkgs mode.
Example Output:
libxml2-2.9.12_2
vim-8.2.3405_2
...
Conclusion
The xbps-query command is a versatile utility that provides various functionalities for querying package and repository information in XBPS. With the examples presented in this article, you can now leverage the power of xbps-query to search for packages, obtain detailed information about installed and remote packages, as well as list and differentiate between manually and automatically installed packages.