有些时候,咱们不得不处理别人用过的系统,或者是一台新安装的系统。由于安全和其它缘由,系统处于最小化安装状态或者选择性安装软件包。一些经常使用的工具命令并无安装。不少人的方式(包括以前的我)经过搜索引擎进行搜索答案。这样的方式效率其实并不高。我以前的博文LINUX下借助YUM和RPM教你正确寻找并安装软件的姿式 其实并不完整。接下来,我从新谈一下完整的方法。git
如下方法基于CENTOS(RHEL)系统centos
假设咱们知道rz这个命令的用法,但系统并无安装。这台服务器能够链接互联网或拥有私有仓库。我须要经过YUM进行查找(经常使用工具或软件包基本都在官方或第三方镜像源BASE,某些工具或软件须要其余第三方源)安全
$ yum provides rz 已加载插件:fastestmirror Loading 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.com lrzsz-0.12.20-36.el7.x86_64 : The lrz and lsz modem communications programs 源 :base 匹配来源: 文件名 :/usr/bin/rz lrzsz-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 已加载插件:fastestmirror Loading 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.com net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools 源 :installed 匹配来源: 文件名 :/usr/bin/netstat
可见,netstat命令是基础网络工具,并被封装在net-tools包内ide
经过YUM INSTLL 安装后,你就能够经过RPM描述查找包内其它工具工具
rpm -qi net-tools Name : net-tools Version : 2.0 Release : 0.17.20131004git.el7 Architecture: x86_64 Install Date: 2016年01月30日 星期六 18时18分27秒 Group : System Environment/Base Size : 938653 License : GPLv2+ Signature : RSA/SHA256, 2014年07月04日 星期五 11时56分18秒, Key ID 24c6a8a7f4a80eb5 Source RPM : net-tools-2.0-0.17.20131004git.el7.src.rpm Build Date : 2014年06月10日 星期二 12时15分04秒 Build Host : worker1.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://sourceforge.net/projects/net-tools/ Summary : Basic networking tools Description : 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等命令。描述就是一个概况,想要详细看看包的具体内容,能够经过以下方法:ui
╰$ 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 ntp Name : ntp Version : 4.2.6p5 Release : 22.el7.centos.2 Architecture: x86_64 Install Date: 2019年04月01日 星期一 14时58分16秒 Group : System Environment/Daemons Size : 1434261 License : (MIT and BSD and BSD with advertising) and GPLv2 Signature : RSA/SHA256, 2016年05月31日 星期二 19时37分00秒, Key ID 24c6a8a7f4a80eb5 Source RPM : ntp-4.2.6p5-22.el7.centos.2.src.rpm Build Date : 2016年05月31日 星期二 18时29分03秒 Build Host : worker1.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://www.ntp.org Summary : The NTP daemon and utilities Description : The Network Time Protocol (NTP) is used to synchronize a computer's time with another reference time source. This package includes ntpd (a daemon which continuously adjusts system time) and utilities used to 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 已加载插件:fastestmirror Loading 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.com ntp-perl-4.2.6p5-28.el7.centos.noarch : NTP utilities written in Perl 源 :base 匹配来源: 文件名 :/usr/sbin/ntptrace