1、查看所有被占用端口:netstat -ntulp
(base) qiang@09230:~$ netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp6 0 0 :::3306 :::* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 :::1314 :::* LISTEN -
tcp6 0 0 :::33060 :::* LISTEN -
udp 0 0 127.0.0.53:53 0.0.0.0:* -
udp 0 0 0.0.0.0:123 0.0.0.0:* -
udp6 0 0 ::1:123 :::* -
udp6 0 0 :::123 :::* -
(base) qiang@09230:~$
2、查看某个端口被占用情况:netstat -ntulp | grep 端口号
(base) qiang@09230:~$ netstat -ntulp | grep 3306
tcp6 0 0 :::3306 :::* LISTEN -
tcp6 0 0 :::33060 :::* LISTEN -
(base) qiang@09230:~$
如果本文对您有所帮助请点赞收藏,支持博主继续输出更好的文章。