故障排除:CentOS 7 – 找不到netstat命令

最近,我在CentOS 7上进行一项工作,并想要验证它是否在监听端口80,使用netstat命令。

你猜怎么着?当我执行netstat时,我得到了下面的错误。

[root@instance-1 init.d]# netstat -anlp |grep 80
-bash: netstat: command not found
[root@instance-1 init.d]#

解决方法:-

使用yum命令安装net-tools

yum install net-tools

例如:

[root@instance-1 init.d]# yum install net-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.xmission.com
 * epel: mirror.hmc.edu
 * extras: centos.s.uw.edu
 * updates: mirrors.syringanetworks.net
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================================================
 Package                                      Arch                                Version                                                Repository                          Size
===============================================================================================================================================================
Installing:
 net-tools                                    x86_64                              2.0-0.22.20131004git.el7                               base                                305 k
Transaction Summary
===============================================================================================================================================================
Install  1 Package
Total download size: 305 k
Installed size: 917 k
Is this ok [y/d/N]: y
Downloading packages:
net-tools-2.0-0.22.20131004git.el7.x86_64.rpm                                                                                      | 305 kB  00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.22.20131004git.el7.x86_64                                                                                                      1/1
  Verifying  : net-tools-2.0-0.22.20131004git.el7.x86_64                                                                                                      1/1
Installed:
  net-tools.x86_64 0:2.0-0.22.20131004git.el7

Complete!
[root@instance-1 init.d]#

然后我就能够使用netstat了。

[root@instance-1 init.d]# netstat -anlp |grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1818/nginx: master
[root@instance-1 init.d]#

我希望这能帮助你解决CentOS 7上的netstat未找到错误

类似文章