How to find which package certain command belongs to on CentOS?

For example I can easily find locate command belongs to mlocate.i386 package.

yum search locate
mlocate.i386 : An utility for finding files by name
[mirror@home /]$ rpm -qa | grep locate
mlocate-0.15-1.el5.1

yum search updatedb
Loaded plugins: fastestmirror, protectbase
0 packages excluded due to repository protections
=========================================== Matched: updatedb ===========================================
mlocate.i386 : An utility for finding files by name

But it's not so easy to find which package free command belongs to:

yum search free   // this command just returns too much informationy 
rpm -qa | grep free
freetype-2.2.1-31.el5_8.1   // obviously not the package by which free command is installed

So is there any convinent way to know which package a specific command belongs to on Linux? For example CentOS or some other distributions


Query the rpmdb.

rpm -qf $(which free)

Ubuntu / Debian example to check the package of the free command:

dpkg -S $(which free)

For CentOS, how about yum provides?

Use

which free 

to find out where it is

For me it's at

/usr/bin/free

So then you can run

yum provides /usr/bin/free

and it will tell you which package has it


For all red-hat based distributions you can use yum package management utility

yum provides `which free`

provides argument specifies which package provides certain feature or file.