Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the command to list what rpms could provide a particular file: the rpm that provide files already installed or rpms that could provide files that are not installed?

share|improve this question
up vote 6 down vote accepted

For already installed files/packages:

[jb@smokey ~]$ rpm -qf /etc/sudoers

For not-yet-installed files & packages:

[jb@smokey ~]$ yum whatprovides "/etc/sudoers"
sudo-1.6.9p13-8.fc9.x86_64 : Allows restricted root access for specified users
Repo        : updates-newkey
Matched from:
Filename    : /etc/sudoers  

sudo-1.6.9p13-4.fc9.x86_64 : Allows restricted root access for specified users
Repo        : fedora
Matched from:
Filename    : /etc/sudoers

sudo-1.6.9p13-8.fc9.x86_64 : Allows restricted root access for specified users
Repo        : installed
Matched from:
Other       : Provides-match: /etc/sudoers

Note that "yum whatprovides " is a pattern match, so if you're not sure where the file you're looking for would live in the directory structure just surround it with quotes and asterisks:

yum whatprovides "*foo*"

Similarly if you're sure what you're looking for is a binary you can do:

yum whatprovides "*bin/foo"
share|improve this answer
Thanks for the detailed answer. – David Nehme Jan 19 '10 at 22:50

I don't know about files not installed already but for a file that is already installed you can use rpm -qif:

rpm -qif /bin/ls
Name        : coreutils                    Relocations: (not relocatable)
Version     : 5.97                              Vendor: Red Hat, Inc.
Release     : 23.el5                        Build Date: Mon 13 Jul 2009 04:21:27 AM MDT
Install Date: Fri 11 Sep 2009 04:46:01 AM MDT      Build Host:
Group       : System Environment/Base       Source RPM: coreutils-5.97-23.el5.src.rpm
Size        : 9053874                          License: GPLv2+
Signature   : DSA/SHA1, Tue 28 Jul 2009 03:42:40 AM MDT, Key ID 5326810137017186
Packager    : Red Hat, Inc. 
URL         :
Summary     : The GNU core utilities: a set of tools commonly used in shell scripts
Description :
These are the GNU core utilities.  This package is the combination of
the old GNU fileutils, sh-utils, and textutils packages.
If you have the RPM downloaded you can query to see what is going to install:
rpm -qilp ./Server/jzlib-1.0.7-4jpp.1.i386.rpm
warning: ./Server/jzlib-1.0.7-4jpp.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Name        : jzlib                        Relocations: (not relocatable)
Version     : 1.0.7                             Vendor: Red Hat, Inc.
Release     : 4jpp.1                        Build Date: Tue 08 Aug 2006 12:10:03 PM MDT
Install Date: (not installed)               Build Host:
Group       : Development/Libraries/Java    Source RPM: jzlib-1.0.7-4jpp.1.src.rpm
Size        : 280436                           License: BSD-style
Signature   : DSA/SHA1, Thu 18 Jan 2007 08:49:50 AM MST, Key ID 5326810137017186
Packager    : Red Hat, Inc. 
URL         : 
Summary     : JZlib re-implementation of zlib in pure Java
Description :
The zlib is designed to be a free, general-purpose, legally unencumbered
-- that is, not covered by any patents -- lossless data-compression
library for use on virtually any computer hardware and operating system.
The zlib was written by Jean-loup Gailly (compression) and Mark Adler
you can omit the "-i" from options if you don't care to see all the info about the RPM.

share|improve this answer

In yum based repositories, you could try something like yum provides */filename

share|improve this answer

afaik, it is not possible with pure rpm. rpm provides this only for installed packages with option --whatprovides.

when you can use yum, try yum provides <filename> to search in the repository.

share|improve this answer

If you don´t want to (or can´t) use yum (e.g. on an offline machine), you can search inside not-installed RPMs by doing

# rpm -qp --filesbypkg *rpms-to-search-in* | grep *file-to-search-for*

This can take some time, so be patient when searching among *.rpm on a large repository, like an install DVD, for example. But, unlike "-qpl", "-qp --filesbypkg" will list both the file and the RPM to which it belongs, for example:

# rpm -qpl p*.rpm|grep

# rpm -qp --filesbypkg p*.rpm|grep
postgresql-libs          /usr/lib/
postgresql-libs          /usr/lib64/

in which case the apparent duplicate is due to the presence of i386 and x86_64 packages (made obvious from the "lib64" string).

share|improve this answer

I'm afraid I'm not sure how to do it with RPMS,but with Debian and Ubuntu you can use the programme apt-file

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.