1、查看占用端口的进程列表
lsof -i:port
[root@localhost ~]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 1849 root 6u IPv4 38588 0t0 TCP *:http (LISTEN)
nginx 1850 www 6u IPv4 38588 0t0 TCP *:http (LISTEN)
nginx 1851 www 6u IPv4 38588 0t0 TCP *:http (LISTEN)
nginx 1852 www 6u IPv4 38588 0t0 TCP *:http (LISTEN)
nginx 1853 www 6u IPv4 38588 0t0 TCP *:http (LISTEN)
2、查看各个占用端口的程序列表
netstat -lnp –ip
[root@localhost ~]# netstat -lnp –ip
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:3306 0.0.0.0:* LISTEN 1714/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1849/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1000/sshd
udp 0 0 0.0.0.0:750 0.0.0.0:* 967/portreserve
udp 0 0 0.0.0.0:636 0.0.0.0:* 967/portreserve
3、查看占用端口的链接的列表
netstat -anp | grep port
[root@localhost ~]# netstat -anp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1849/nginx
tcp 0 0 ::ffff:192.168.1.104:8005 :::* LISTEN 1754/java
tcp 0 0 :::8009 :::* LISTEN 1754/java
tcp 0 0 :::8080 :::* LISTEN 1754/java
unix 2 [ ] DGRAM 10802 1008/crond
转载请注明:IT运维空间 » linux » 在Linux下如何查询那个程序占用了指定端口
发表评论