[yum]06.yum provides和rpm -qf的比较

  在前边说yum的几篇文章中我曾说过如何通过记忆中的一小段包名中的字符串来查找到包名,并举了"setup"这个工具的例子:

image.png

现在我想查看linux系统发行版的信息,用到lsb_release -a命令:

[root@node78 ~]#lsb_release -a
-bash: lsb_release: command not found
[root@node78 ~]#

那我就用上边这种方法查查吧,查到了再使用yum安装:

[root@localhost init.d]# yum list |grep lsb_release
[root@localhost init.d]#

哦,你这不是逗我吗,可能因为我输入的字符串太精准了,少输入点吧,那我grep lsb得了:

[root@localhost init.d]# yum list |grep lsb
redhat-lsb-core.x86_64                      4.1-27.el7.centos.1        @base    
redhat-lsb-submod-security.x86_64           4.1-27.el7.centos.1        @base    
redhat-lsb.i686                             4.1-27.el7.centos.1        base     
redhat-lsb.x86_64                           4.1-27.el7.centos.1        base     
redhat-lsb-core.i686                        4.1-27.el7.centos.1        base     
redhat-lsb-cxx.i686                         4.1-27.el7.centos.1        base     
redhat-lsb-cxx.x86_64                       4.1-27.el7.centos.1        base     
redhat-lsb-desktop.i686                     4.1-27.el7.centos.1        base     
redhat-lsb-desktop.x86_64                   4.1-27.el7.centos.1        base     
redhat-lsb-languages.i686                   4.1-27.el7.centos.1        base     
redhat-lsb-languages.x86_64                 4.1-27.el7.centos.1        base     
redhat-lsb-printing.i686                    4.1-27.el7.centos.1        base     
redhat-lsb-printing.x86_64                  4.1-27.el7.centos.1        base     
redhat-lsb-submod-multimedia.i686           4.1-27.el7.centos.1        base     
redhat-lsb-submod-multimedia.x86_64         4.1-27.el7.centos.1        base     
redhat-lsb-submod-security.i686             4.1-27.el7.centos.1        base     
redhat-lsb-supplemental.x86_64              4.1-27.el7.centos.1        base     
redhat-lsb-trialuse.i686                    4.1-27.el7.centos.1        base     
redhat-lsb-trialuse.x86_64                  4.1-27.el7.centos.1        base

还真巧了,接下来安装:

[root@localhost system]# yum -y install redhat-lsb-core

就可以了。但是这种方法还有一个不足的地方,就是我要grep xxx,这xxx完全靠猜啊,心里总感觉没底啊。在这里我再介绍另外一种方法。因为我们知道lsb_release它是个命令,本质上肯定是在PATH路径下有这么一个同名的文件,慢慢的,真相将要浮出水面了,就是说我现在知道我要找的这个rpm安装包将来安装完成之后一定会有个名字叫做lsb_release的文件。

        现在要介绍的方法就是如何查询包含某个文件名的所有安装包,不管是本机安装的还是没有安装的,你就从yum源上给我列出来,使用命令"yum provides lsb_release",yum provides 参数,这里的参数是你要查询的文件名:

[root@localhost system]# yum provides lsb_release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
base/7/x86_64/filelists_db                                                                                                                                              | 6.7 MB  00:00:11     
extras/7/x86_64/filelists_db                                                                                                                                            | 528 kB  00:00:05     
updates/7/x86_64/filelists_db                                                                                                                                           | 2.7 MB  00:00:27     
redhat-lsb-core-4.1-27.el7.centos.1.i686 : LSB Core module support
Repo        : base
Matched from:
Filename    : /usr/bin/lsb_release

redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support
Repo        : base
Matched from:
Filename    : /usr/bin/lsb_release

看到了吧,接下来我直接使用

[root@localhost system]# yum -y install redhat-lsb-core

就可以安装了。

总结:

    1.yum provides 参数:这里的参数是你要查询的文件名,不管是本机安装的还是没有安装的,都会把信息列出来。这个功能很类似于

"rpm -qf 文件名"这个命令,因为他们都是根据文件名来查询该文件所在的rpm安装包。

     2.yum provides 参数,这里的参数就是一个文件名,没有绝对路径相对路径的要求,而“rpm -qf 文件名”里面的文件名必须是本地已经安装过的真实存在的文件的绝对路径才可以查出它的rpm安装包信息:

[root@localhost ~]# rpm -qf /etc/httpd/conf/httpd.conf 
httpd-2.4.6-67.el7.centos.6.x86_64
[root@localhost ~]# rpm -qf httpd.conf 
error: file /root/httpd.conf: No such file or directory
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值