11

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?

6 Answers 6

11

For already installed files/packages:

[jb@smokey ~]$ rpm -qf /etc/sudoers
sudo-1.6.9p13-8.fc9.x86_64

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"
0
5

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: hs20-bc1-7.build.redhat.com
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: hs20-bc1-6.build.redhat.com
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
(decompression).
/usr/lib/gcj/jzlib/jzlib-1.0.7.jar.db
/usr/lib/gcj/jzlib/jzlib-1.0.7.jar.so
/usr/share/doc/jzlib-1.0.7
/usr/share/doc/jzlib-1.0.7/LICENSE.txt
/usr/share/java/jzlib-1.0.7.jar
/usr/share/java/jzlib.jar
you can omit the "-i" from options if you don't care to see all the info about the RPM.

2

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

1

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.

1

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 libpq.so.4
/usr/lib/libpq.so.4
/usr/lib64/libpq.so.4

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

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

-3

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .