How to use the command 'equery' (with examples)
- Linux
- December 25, 2023
The ’equery’ command is a tool used in Gentoo Linux for viewing information about Portage packages. It provides various options to list installed packages, search for packages, view package dependencies, and list files installed by a package. This article will illustrate each of these use cases with examples.
Use case 1: List all installed packages
Code:
equery list '*'
Motivation: This use case allows users to quickly view a list of all the packages installed on their Gentoo Linux system. It can be helpful for troubleshooting, managing software, and keeping track of installed packages.
Explanation:
- ’equery’: The command itself.
- ’list’: The action to list packages.
- ‘’: The package name pattern. In this case, the asterisk () represents all packages.
Example output:
* Searching for all packages matching *
[IP-] [ ] sys-devel/binutils-2.35.1
[IP-] [ ] sys-apps/baselayout-2.7-r1
[IP-] [ ] sys-apps/busybox-1.33.0
[IP-] [ ] sys-apps/coreutils-8.32
...
Use case 2: Search for installed packages in the Portage tree and in overlays
Code:
equery list -po package1 package2 ...
Motivation: This use case allows users to search for specific packages in both the Portage tree and any overlays they have added. It is useful for finding packages across different sources and verifying if they are installed.
Explanation:
- ’equery’: The command itself.
- ’list’: The action to list packages.
- ‘-po’: The options to perform a search in the Portage tree and overlays.
- ‘package1 package2 …’: The list of packages to search for.
Example output:
* Searching for package1 ...
[IP-] [ ] category/package1-1.0
* Searching for package2 ...
[IP-] [ ] category/package2-2.5-r1
Use case 3: List all packages that depend on a given package
Code:
equery depends package
Motivation: This use case allows users to find all the packages that depend on a specific package. It helps in understanding the impact of removing or modifying a package, as well as troubleshooting dependency issues.
Explanation:
- ’equery’: The command itself.
- ‘depends’: The action to list dependencies.
- ‘package’: The name of the package to check for dependencies.
Example output:
* These packages depend on package:
[OK] sys-apps/package-utils-0.12.3-r3
[...] ...
Use case 4: List all packages that a given package depends on
Code:
equery depgraph package
Motivation: This use case allows users to view a graphical representation of package dependencies. It helps in understanding the relationships between packages and their dependencies, aiding in troubleshooting and system maintenance.
Explanation:
- ’equery’: The command itself.
- ‘depgraph’: The action to display the dependency graph.
- ‘package’: The name of the package to visualize dependencies for.
Example output:
* Graph-based dependency overview for package:
├─┬ category/dependency-package-1.2
│ └── category/another-package-2.0
├── category/yet-another-package-3.1
├─┬ category/some-package-4.7
│ ├── category/dependency-package-1.2
│ ├── category/yet-another-package-3.1
...
## Use case 5: List all files installed by a package
Code:
```shell
equery files --tree package
Motivation: This use case allows users to see a tree-like structure of files installed by a specific package. It helps in tracking down files associated with a package, identifying conflicting files from different packages, and managing package contents.
Explanation:
- ’equery’: The command itself.
- ‘files’: The action to list installed files.
- ‘–tree’: The option to display the files in a tree-like structure.
- ‘package’: The name of the package to check files for.
Example output:
* Contents of package:
/usr/
├─ /bin/
│ └── executable-file
└─ /etc/
└── configuration-file
...
Conclusion:
The ’equery’ command in Gentoo Linux is a versatile tool for managing Portage packages. By using its various options, users can list installed packages, search across the Portage tree and overlays, view package dependencies, and list installed files. These features provide users with valuable insights into their system and aid in package management and troubleshooting.