Find which installed RPM owns /usr/bin/bash.
Perform a reverse lookup from the file path in the RPM database.
Which command is appropriate?
rpm -qf FILE searches the installed RPM database for the package that owns the specified path.
Detailed explanation
rpm -ql /usr/bin/bashIncorrect. -ql expects a package name and lists its files.
Incorrect. -ql expects a package name and lists its files.
rpm -qf /usr/bin/bashCorrect. rpm -qf /usr/bin/bash reports the owning installed package.
Correct. rpm -qf /usr/bin/bash reports the owning installed package.
rpm -qp /usr/bin/bashIncorrect. -p makes a query target an RPM archive, not the installed database.
Incorrect. -p makes a query target an RPM archive, not the installed database.
rpm -qR /usr/bin/bashIncorrect. -qR lists requirements of a package.
Incorrect. -qR lists requirements of a package.
Try it yourself
An example you can run in a temporary verification environment.
rpm --help | grep -E -- '--file|-f'Expected result
file owner queryの説明Key points
- -f means file ownership
- Pass a file path
- The installed database is queried
Notes
- Environment: RPM 4.19〜6.x公式仕様
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.