Linux – rpm that provides a file

linuxrpm

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?

Best Answer

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"