Thursday, 24 October 2013

Finding process path associated to a port on linux

Problem: I want to find out process path that is associated to port 8080 on my linux system.

We can use netstat along with grep to do this.

 [root@dragon ~]# netstat -tulpn | grep 8080

 tcp        0      0      *                   LISTEN      14491/./haproxy-1.4

In the above command. We can observe ./haproxy-1.4 is a process with process id 14491 is associated to port 8080.

We can use ps command to find out process path associated to process id

 [root@dragon ~]# ps -aef | grep 14491 

80       14491     1  0 Oct24 ?        00:00:04 ./haproxy-1.4.24-pcre-40kses-linux-i586.stripped -f /etc/haproxy/haproxy.cfg

We can observe haproxy was started using command:

./haproxy-1.4.24-pcre-40kses-linux-i586.stripped -f /etc/haproxy/haproxy.cfg

No comments:

Post a Comment