步骤一:
linux使用netstat或者ifconfig命令时,显示命令未找到。
通过yum search netstat这个命令,匹配结果如下:
================================= 匹配:netstat ===================
bwm-ng.x86_64 : Bandwidth Monitor NG
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
python2-psutil.x86_64 : A process and system utilities module for Python
python34-psutil.x86_64 : A process and system utilities module for Python
unhide.x86_64 : Tool to find hidden processes and TCP/UDP ports from rootkits
运行yum install net-tools 就OK了
netstat和ifconfig命令在安装了net-tools后都可以使用了。
步骤二
查询被占用的端口。首先是需要输入命令,查看被占用的端口的进程
netstat -tunlp | grep 端口号
-
-t (tcp) 仅显示tcp相关选项
-
-u (udp)仅显示udp相关选项
-
-n 拒绝显示别名,能显示数字的全部转化为数字
-
-l 仅列出在Listen(监听)的服务状态
-
-p 显示建立相关链接的程序名
-
例如查看 8000 端口的情况,使用以下命令:
-
根据集成id查询进程。如果想详细查看这个进程,ID具体是哪一个进程,可以通过命令的方式进行查看进程的详细信息,
ps -ef|grep 进程ID