使用 netstat 进行查看!
>netstat -noap | grep 80 | grep tcp
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
-----------------------------------------------------------------------------------------------------------------
tcp 74160 138880 127.0.0.1:6150 127.0.0.1:6150 ESTABLISHED 3145/tnslsnr unkn-4 (52.04/0/0)
tcp 0 0 :::8009 :::* LISTEN 31550/java off (0.00/0/0)
tcp 0 0 :::8080 :::* LISTEN 31550/java off (0.00/0/0)
tcp 0 0 :::80 :::* LISTEN 24675/httpd off (0.00/0/0)
使用 lsof 进行查看!
谁在使用tcp8080端口
lsof -i tcp:8080
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
------------------------------------------------------
java 31550 root 109u IPv6 78687600 TCP *:webcache (LISTEN)
谁在使用22端口
lsof -i :22
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
sshd 2883 root 3u IPv6 7642 TCP *:ssh (LISTEN)
然后根据 pid
使用ps -ef | grep pid去查是哪里占用了