博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
再谈CENTOS下通过YUM和RPM快速获取相关工具(命令)所在软件包并安装
阅读量:7086 次
发布时间:2019-06-28

本文共 4137 字,大约阅读时间需要 13 分钟。

有些时候,我们不得不处理别人用过的系统,或者是一台新安装的系统。因为安全和其它原因,系统处于最小化安装状态或者选择性安装软件包。一些常用的工具命令并没有安装。很多人的方式(包括之前的我)通过搜索引擎进行搜索答案。这样的方式效率其实并不高。我之前的博文 其实并不完整。接下来,我重新谈一下完整的方法。

以下方法基于CENTOS(RHEL)系统

假设我们知道rz这个命令的用法,但系统并没有安装。这台服务器可以连接互联网或拥有私有仓库。我需要通过YUM进行查找(常用工具或软件包基本都在官方或第三方镜像源BASE,某些工具或软件需要其他第三方源)

$ yum provides rz     已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * elrepo: mirrors.tuna.tsinghua.edu.cn * epel: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.comlrzsz-0.12.20-36.el7.x86_64 : The lrz and lsz modem communications programs源    :base匹配来源:文件名    :/usr/bin/rzlrzsz-0.12.20-36.el7.x86_64 : The lrz and lsz modem communications programs源    :@base匹配来源:文件名    :/usr/bin/rz

该命令可以查找某工具或命令位于哪个包(当前为lrzsz) 并提供了包的仓库的地址(BASE库 -阿里云CENTOS镜像)并提供命令位置(安装位置和是否安装没有直接关联)

有些时候,基于系统的基础工具被打在一个包内,你可能并不知道这个包名,同样的方法也可以查找,比如netstat

yum provides netstat   已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * elrepo: mirrors.tuna.tsinghua.edu.cn * epel: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.comnet-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools源    :installed匹配来源:文件名    :/usr/bin/netstat

可见,netstat命令是基础网络工具,并被封装在net-tools包内

通过YUM INSTLL 安装后,你就可以通过RPM描述查找包内其它工具

rpm -qi net-toolsName        : net-toolsVersion     : 2.0Release     : 0.17.20131004git.el7Architecture: x86_64Install Date: 2016年01月30日 星期六 18时18分27秒Group       : System Environment/BaseSize        : 938653License     : GPLv2+Signature   : RSA/SHA256, 2014年07月04日 星期五 11时56分18秒, Key ID 24c6a8a7f4a80eb5Source RPM  : net-tools-2.0-0.17.20131004git.el7.src.rpmBuild Date  : 2014年06月10日 星期二 12时15分04秒Build Host  : worker1.bsys.centos.orgRelocations : (not relocatable)Packager    : CentOS BuildSystem 
Vendor : CentOSURL : http://sourceforge.net/projects/net-tools/Summary : Basic networking toolsDescription :The net-tools package contains basic networking tools,including ifconfig, netstat, route, and others.Most of them are obsolete. For replacement check iproute package.

描述内说明这个包还包含了ifconfig和route等命令。描述就是一个概况,想要详细看看包的具体内容,可以通过如下方法:

╰$ rpm -ql net-tools/bin/netstat/sbin/arp/sbin/ether-wake/sbin/ifconfig/sbin/ipmaddr/sbin/iptunnel/sbin/mii-diag/sbin/mii-tool/sbin/nameif/sbin/plipconfig/sbin/route/sbin/slattach/usr/lib/systemd/system/arp-ethers.service/usr/share/doc/net-tools-2.0/usr/share/doc/net-tools-2.0/COPYING/usr/share/locale/cs/LC_MESSAGES/net-tools.mo...

我省略了部分输出,即很多man文件

描述其实很有用,比如在RHEL(centos6)以上,ntp包已经不含ntptrace命令了。而是在ntp-perl包中

$ rpm -qi ntpName        : ntpVersion     : 4.2.6p5Release     : 22.el7.centos.2Architecture: x86_64Install Date: 2019年04月01日 星期一 14时58分16秒Group       : System Environment/DaemonsSize        : 1434261License     : (MIT and BSD and BSD with advertising) and GPLv2Signature   : RSA/SHA256, 2016年05月31日 星期二 19时37分00秒, Key ID 24c6a8a7f4a80eb5Source RPM  : ntp-4.2.6p5-22.el7.centos.2.src.rpmBuild Date  : 2016年05月31日 星期二 18时29分03秒Build Host  : worker1.bsys.centos.orgRelocations : (not relocatable)Packager    : CentOS BuildSystem 
Vendor : CentOSURL : http://www.ntp.orgSummary : The NTP daemon and utilitiesDescription :The Network Time Protocol (NTP) is used to synchronize a computer'stime with another reference time source. This package includes ntpd(a daemon which continuously adjusts system time) and utilities usedto query and configure the ntpd daemon.Perl scripts ntp-wait and ntptrace are in the ntp-perl package,ntpdate is in the ntpdate package and sntp is in the sntp package.The documentation is in the ntp-doc package.

当然,RPM检索包的前期是必须将软件包安装在本地,否则你会看到

╰$ rpm -ql ntp-perl未安装软件包 ntp-perl

而YUM的前提是你的YUM源中拥有这个软件包

$ yum provides ntptrace已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * elrepo: mirrors.tuna.tsinghua.edu.cn * epel: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.comntp-perl-4.2.6p5-28.el7.centos.noarch : NTP utilities written in Perl源    :base匹配来源:文件名    :/usr/sbin/ntptrace

转载于:https://blog.51cto.com/z00w00/2385026

你可能感兴趣的文章
不断被取代的传统职业:快速发展的智能交互
查看>>
时尚领秀,潮起温州 | 开宸聚合全新概念于2017温州时尚生活展
查看>>
强大的跨数据库访问组件 UniDAC使用教程:DataSet Manager
查看>>
五分钟跑起来快应用
查看>>
简单的python代码实现语音朗读
查看>>
SaaS加速器 III 技术中心:提供SaaS Launchkit,快速定制,一云多端等能力,一云多端将通过小程序云实现...
查看>>
使用 QuickBI 搭建酷炫可视化分析
查看>>
Python基础
查看>>
sublime text3使用笔记
查看>>
VirtuaNES.v0.97源码探究<5> 内存查看器
查看>>
我的友情链接
查看>>
Mysql基于FEDERATED存储引擎的远程表使用
查看>>
28. C# -- 抽象类和抽象方法
查看>>
archlinux安装go语言开发环境
查看>>
转存:常用正则表达式
查看>>
J2EE Comparator、Comparable的比较学习
查看>>
现在4位字母5数字的域名.com已经没有了 转让5数字域名
查看>>
Instant Radiosity
查看>>
多线程的互斥
查看>>
创建redis集群时出现no such fileto load -- rubygems问题的解决
查看>>