1. 序言
如笔者在本机上运行netstat时,提示没有这个命令,向来简单粗暴,直接yum -y install netstat,显然是不能正常安装的。
[root@hadoop-103 ~]# yum -y install netstat
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): extras/7/x86_64/primary_db | 153 kB 00:00:00
(2/2): updates/7/x86_64/primary_db | 5.1 MB 00:00:02
No package netstat available.
Error: Nothing to do
[root@hadoop-103 ~]#
这种情况下,怎么办呢?
2. 使用“yum search”命令
此时可以使用“yum search”来查询这个命令在哪个包中:
[root@hadoop-103 ~]$ yum search netstat
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
========================================================= Matched: netstat =========================================================
dstat.noarch : Versatile resource statistics tool
net-snmp.x86_64 : A collection of SNMP protocol tools and libraries
net-tools.x86_64 : Basic networking tools #这里已经给出了netstat命令所在包
接着直接安装这个包即可:yum -y install net-tools
3.使用“yum whatprovides ”查询命令所在的包
还可以使用yum whatprovides
[root@hadoop-103 ~]# yum whatprovides *netstat
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base/7/x86_64/filelists_db | 7.3 MB 00:00:04
extras/7/x86_64/filelists_db | 207 kB 00:00:00
updates/7/x86_64/filelists_db | 3.0 MB 00:00:01
1:net-snmp-utils-5.7.2-43.el7.x86_64 : Network management utilities using SNMP, from the NET-SNMP project
Repo : base
Matched from:
Filename : /usr/bin/snmpnetstat
net-tools-2.0-0.25.20131004git.el7.x86_64 : Basic networking tools
Repo : base
Matched from:
Filename : /bin/netstat
zsh-5.0.2-33.el7.x86_64 : Powerful interactive shell
Repo : base
Matched from:
Filename : /usr/share/zsh/5.0.2/functions/_netstat
net-tools-2.0-0.24.20131004git.el7.x86_64 : Basic networking tools
Repo : @base
Matched from:
Filename : /bin/netstat
[root@hadoop-103 ~]#
参考链接:https://blog.csdn.net/xuejinliang/article/details/52777475