在Linux下查看端口占用情况,可以使用如下命令:
netstat -apn
该命令查看所有进程和端口的使用情况,显示结果如下:
<Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:10000 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:51413 0.0.0.0:* LISTEN 9007/transmission-g
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
如果想直接查找某程序或者某进程占用情况可以使用如下命令:
netstat -apn | grep 程序名/PID
这样就可以进行判断,是否采用kill操作了。