当系统中有一个命令的时候,通过 rpm -qf /path/to/command 可以查到这个命令是由哪个软件包安装的。但是,如果说需要用的这个命令不存在呢,该如何找到能提供这个命令的软件包。

通过yum能够解决这个问题

# yum help | grep provides
provides       Find what package provides the given value

比如,需要查找 genhash 这个命令由哪个命令提供,

# yum provides */genhash
keepalived-1.2.7-3.el6.x86_64 : High Availability monitor built upon LVS, VRRP and service pollers
Repo        : CentOS64
Matched from:
Filename    : /usr/bin/genhash

注意,需要查找的内容前面需要加上 */ 或者 *bin/ ,否则可能查找不到

# yum provides genhash  
Warning: 3.0.x versions of yum would erroneously match against filenames.
 You can use "*/genhash" and/or "*bin/genhash" to get that behaviour
No Matches found