Several ways to check port occupancy in Linux

 In Linux, you can use the following methods to check the port usage.

1. Use the netstat command

#安装netstat
yum -y install net-tools
#检测端口占用
netstat -npl | grep 端口

# 几种常规用法
netstat -ntlp   //查看当前所有tcp端口
netstat -ntulp | grep 80   //查看所有80端口使用情况
netstat -ntulp | grep 3306   //查看所有3306端口使用情况

Second, use the lsof command

#安装lsof
yum -y install lsof
#检测端口占用
lsof -i: 端口号

3. Use the psmisc command

#安装psmisc
yum -y install psmisc
#检测端口占用,如果占用,能够查到pid
fuser 端口/tcp

Guess you like

Origin blog.csdn.net/qq_19309473/article/details/132725745