linux查找某个命令属于哪个rpm包

我们拿pip命令来举例

   

方法一:

确认命令的路径

# which pip     

/usr/bin/pip

   

yum命令查找pip属于哪个rpm

yum whatprovides /usr/bin/pip

   

   

Loaded plugins: fastestmirror, refresh-packagekit, security    

Loading mirror speeds from cached hostfile    

* base: mirrors.sina.cn    

* epel: mirrors.ustc.edu.cn    

* extras: mirrors.zju.edu.cn    

* updates: mirrors.zju.edu.cn    

python-pip-7.1.0-1.el6.noarch : A tool for installing and managing Python packages    

Repo        : epel    

Matched from:    

Filename    : /usr/bin/pip

python-pip-7.1.0-1.el6.noarch : A tool for installing and managing Python packages   

Repo        : installed    

Matched from:

   

根据上述信息,可知pip来自python-pip-7.1.0-1.el6.noarch这个包.

另外yum provides/whatprovides接受通配符选项:

假如不知道命令的路径,也可以用通配来解决

yum whatprovides *pip

关于yum的其它用法可以man yum查看

   

方法二:

确认命令的路径

# whereis pip

pip: /usr/bin/pip2.6 /usr/bin/pip

   

查找命令属于那个安装包

# rpm -qf /usr/bin/pip   

python-pip-7.1.0-1.el6.noarch

   

列出这个rpm包中的所有文件

# rpm -ql python-pip-7.1.0-1.el6.noarch

查询是否安装某个rpm.

rpm –qa python-pip

原文地址:https://www.cnblogs.com/liuxia912/p/10962392.html