Find the corresponding program through the port under Linux

For example, we know port 5600 is occupied, you need to find what program takes up, you can find the following manner.
1. Open the port corresponding to first find the PID of the program by lsof command.

[yuanping@Linux C]$ lsof -i :5600
COMMAND  PID     USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
server  4643 yuanping    3u  IPv4 1286699      0t0  TCP *:esmmanager (LISTEN)

2. Find the corresponding file by PID, PID 4643 is a step above where found in the program.

[yuanping@Linux C]$ ls -l /proc/4643/exe
lrwxrwxrwx. 1 yuanping yuanping 0 Jan  8 23:08 /proc/4643/exe -> /home/yuanping/Code/C/server
[yuanping@Linux C]$ 

Or it may be accomplished by a statement in which 5600 into your port.

[yuanping@Linux C]$ ls -l /proc/`lsof -i :5600 | awk -F " " '{print $2}' | grep -v "PID" | sort | uniq`/exe
lrwxrwxrwx. 1 yuanping yuanping 0 Jan  8 23:08 /proc/4643/exe -> /home/yuanping/Code/C/server
[yuanping@Linux C]$ 

 

Reproduced in: https: //www.cnblogs.com/yuanping/archive/2013/01/08/2852065.html

Guess you like

Origin blog.csdn.net/weixin_33904756/article/details/94067250