1、利用lsof -i:端口号
lsof -i:端口号
[root@01 ~]# lsof -i:8097
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 24033 root 323u IPv6 124173190 0t0 TCP *:sac (LISTEN)
2、利用netstat查看端口号的进程,如下24033为进程号
[root@01 ~]# netstat -apn|grep 8097
tcp 0 0 10.72.23.48:54213 10.72.23.48:8097 TIME_WAIT -
tcp 0 0 :::8097 :::* LISTEN 24033/java
再根据进程号查看进程
[root@01 ~]#ps -ef|grep 24033
root 12952 12167 0 09:06 pts/0 00:00:00 grep 24033
root 24033 1 1 Mar27 ? 00:40:14 /opt/java/jdk1.7.0_25/bin/java -javaagent:/opt/java/jetty7/tingyun/tingyun-agent-java.jar -Xmx2560m -Xms2560m -Xmn512m -XX:PermSize=512m -XX:MaxPermSize=512m -Xss256k -Djetty.home=/opt/java/jetty7 -Djava.io.tmpdir=/tmp -jar /opt/java/jetty7/start.jar --pre=etc/jetty-logging.xml etc/jetty-jmx.xml
3、利用ss
ss -lp 找出打开套接字/端口应用程序
找出8090端口的进程
[root@01 ~]# ss -lp | grep 8090
LISTEN 0 50 :::8090 :::* users:(("java",1661,489))
进程号为1661
[root@01 ~]# ps -ef|grep 1661
root 1661 1 2 Mar27 ? 01:14:00 /opt/java/jdk1.7.0_25/bin/java -javaagent:/opt/java/jetty2/tingyun/tingyun-agent-java.jar -Xmx2560m -Xms2560m -Xmn512m -XX:PermSize=512m -XX:MaxPermSize=512m -Xss256k -Djetty.home=/opt/java/jetty2 -Djava.io.tmpdir=/tmp -jar /opt/java/jetty2/start.jar --pre=etc/jetty-logging.xml etc/jetty-jmx.xml
进程489为grep进程
[root@01 ~]# ps -ef|grep 489
root 19395 12167 0 10:25 pts/0 00:00:00 grep 489