Finding Which RPM Package Contains a File
October 15th, 2008 by Dashamir Hoxha in
To search a list of RPM files for a particular file, execute the following command:
$ ls RPMS-TO-SEARCH | \
xargs rpm --query --filesbypkg --package | \
grep FILE-TO-SEARCH-FOR
Replace RPMS-TO-SEARCH with the names of the RPM files to search, and replace FILE-TO-SEARCH-FOR with the name of the file to search for. The --filesbypkg option tells the rpm command to output the name of the package as well as the name of the file.
__________________________
Special Magazine Offer -- Free Gift with Subscription
Receive a free digital copy of Linux Journal's System Administration Special Edition as well as instant online access to current and past issues. CLICK HERE for offer
Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.
Subscribe now!
The Latest
Newsletter
Tech Tip Videos
- Nov-19-09
- Nov-04-09
Recently Popular
From the Magazine
December 2009, #188
If last month's Infrastrucuture issue was too "big" for you then try on this month's Embedded issue. Find out how to use Player for programming mobile robots, build a humidity controller for your root cellar, find out how to reduce the boot time of your embedded system, and if you're new to embedded systems find out the basics that go into one. You can also read about the Beagle Board, the Mesh Potato and a spate of other interestingly named items. And along with our regular columns don't miss our new monthly column: Economy Size Geek.
Delicious
Digg
StumbleUpon
Reddit
Facebook








Correction for "Another way"
On October 16th, 2008 Anonymous (not verified) says:
D**n... Missed the stated intent of searching uninstalled packages.
The "--whatprovides" switch naturally only searches packages already installed on the system, not the package files.
Sorry for that.
Another way to find the file.
On October 16th, 2008 Anonymous (not verified) says:
Or You could just use RPM's database.
rpm -q --whatprovides FILES_TO_SEARCH_FOR
Other Usefull rpm commands
On October 15th, 2008 Rui Lapa (not verified) says:
Same as:
rpm -qlp RPMS-TO-SEARCH | \
grep FILE-TO-SEARCH-FOR
q - query
l - list files
p - packages
Good ones are:
--------------
1. Find the rpm which FILE (path/filename) belongs to
rpm -qf FILE
2. Verify rpm files (changes, MD5, permissions, owner, ...)
rpm -qV RPM_PACKAGE_NAME
3. List packages ordered by SIZE
rpm -qa --qf "%{SIZE} %{NAME}\n" | sort -n
4. Repackage OLD files (make rollback rpm) when upgrading an rpm
rpm --repackage -Uvh NEW_RPM_PACKAGE
rpm -qlp RPMS-TO-SEARCH |
On March 6th, 2009 Patricio Diaz (not verified) says:
rpm -qlp RPMS-TO-SEARCH | grep FILE-TO-SEARCH-FOR will tell you the file name, the directory it will be installed on, and that there is a package containing it, but won't tell you which package is.
Post new comment