How to find which package an application is in

I recently installed a minimal version of Centos 6, which meant that many of the basic tools were not installed by default.

But how do you find which package a tool or application is in? Sometimes it’s as easy as just giving the name of what you want, but often this isn’t possible if an application is part of a package that has to be installed to use it, and that package name is different.

So how do we find out what package provides a file/application/feature? We could Google it if the internerd is available. If it’s not, you can simply use the whatprovides command in Yum (this should also be faster than Googling for the answer!)

yum whatprovides "*/whois"

In this case, we provide the filename and path, but because I’m not sure where the file usually resides, I’ve used a wildcard to search with.

Below is the output from the above command:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.bytemark.co.uk
 * extras: mirror.bytemark.co.uk
 * updates: mirror.bytemark.co.uk
irssi-0.8.15-3.el6.i686 : Modular text mode IRC client with Perl scripting
Repo        : base
Matched from:
Filename    : /usr/share/irssi/help/whois

jakarta-commons-net-javadoc-2.0-2.1.el6.noarch : Javadoc for jakarta-commons-net
Repo        : base
Matched from:
Filename    : /usr/share/javadoc/jakarta-commons-net-2.0/org/apache/commons/net/whois

jwhois-4.0-19.el6.i686 : Internet whois/nicname client
Repo        : base
Matched from:
Filename    : /usr/bin/whois

You may get several results and may have to work out which it is you need. However, in this case, the result most obvious is the last – jwhois (on a side note, you do not use the version numbers, etc., just the initial filename.)