有些時候,咱們不得不處理別人用過的系統,或者是一臺新安裝的系統。由於安全和其它緣由,系統處於最小化安裝狀態或者選擇性安裝軟件包。一些經常使用的工具命令並無安裝。不少人的方式(包括以前的我)經過搜索引擎進行搜索答案。這樣的方式效率其實並不高。我以前的博文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