如何在 CentOS 上查找某个命令属于哪个包?

hug*_*eow 23 linux centos package-management command-line

例如我可以很容易地找到属于 mlocate.i386 包的 locate 命令。

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
Run Code Online (Sandbox Code Playgroud)

但是要找到哪个 package free 命令并不那么容易:

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
Run Code Online (Sandbox Code Playgroud)

那么有没有什么方便的方法可以知道特定命令在 Linux 上属于哪个包?例如 CentOS 或其他一些发行版

Jer*_*ost 27

Ubuntu/Debian示例检查包的free命令:

dpkg -S $(which free)
Run Code Online (Sandbox Code Playgroud)


Ign*_*ams 17

查询rpmdb。

rpm -qf $(which free)
Run Code Online (Sandbox Code Playgroud)


小智 8

对于 CentOS,yum 提供的怎么样?

which free 
Run Code Online (Sandbox Code Playgroud)

找出它在哪里

对我来说是

/usr/bin/免费

那么你可以运行

yum provides /usr/bin/free
Run Code Online (Sandbox Code Playgroud)

它会告诉你哪个包有它