RPM query mode: Which rpm command option is used to query information about a specific package (for example, to check if it is installed)?

Difficulty: Easy

Correct Answer: rpm -q

Explanation:


Introduction / Context:
Querying installed packages is a routine task in system administration. The rpm tool provides a query mode that quickly answers questions such as whether a package is installed, its version, and which files it installed.



Given Data / Assumptions:

  • The system uses RPM-based packaging.
  • We want to query package information, not install or remove it.
  • We are using the low-level rpm command, not higher-level tools like dnf or yum.


Concept / Approach:

The -q option enables query mode. You can use rpm -q packagename to check installation and version, rpm -qi packagename for detailed info, and rpm -ql packagename to list installed files. Other letters have different purposes (for example, -i for install, -e for erase).



Step-by-Step Solution:

Choose the query switch: -qCheck existence/version: rpm -q packagenameGet details: rpm -qi packagenameList files: rpm -ql packagename


Verification / Alternative check:

Compare output with dnf list installed or rpm -qa | grep packagename. All methods corroborate whether a package is present.



Why Other Options Are Wrong:

  • rpm -a: Not a valid standalone query; common is -qa (query all). As shown, -a alone does not mean “query package”.
  • rpm -d: Not a standard query option for rpm; often misremembered from other tools.
  • rpm -1: Invalid option (and “-1” is not a recognized flag).
  • None of the above: Incorrect; rpm -q is correct.


Common Pitfalls:

Forgetting to combine flags properly (for example, using -qa to list all packages). Confusing rpm query capabilities with repository-enabled tools like dnf that can query remote repos.



Final Answer:

rpm -q

More Questions from Linux

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion