Linux查端口占用的几种方式

 在Linux中,你可以使用以下几种方式来查看端口的占用情况。

一、使用netstat命令

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

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

二、使用lsof命令

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

三、使用psmisc命令

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

猜你喜欢

转载自blog.csdn.net/qq_19309473/article/details/132725745