John’s Oracle Experiences

My everyday experiences with Oracle products

Archive for January 3rd, 2009

Wondering which process is listening on a specific port ?

Posted by John Paul van Helvoort on January 3, 2009

Sometimes i am wondering which process is listening on a specific port i want to use.
In order to see the process listening on a specific port , i am using this trick :

[] xxx:oracle> netstat -an | grep 7780
tcp 0 0 0.0.0.0:7780 0.0.0.0:* LISTEN

There is a process listening on port 7780. Now lets check which process is listening on this port :

[] xxx:oracle> lsof -i TCP:7780
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
httpd 4476 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 4480 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 4482 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 4484 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 4487 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 4489 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 4490 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 4496 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 4515 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 4519 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 7630 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 7633 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 7636 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 11468 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 11532 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 11632 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 11861 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 12084 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 12088 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
httpd 28920 oracle 16u IPv4 1752332551 TCP *:7780 (LISTEN)
[] xxx:oracle>

As you can see its the httpd process which has multiple process listening here.
This is really handy to use whenever you are confused on which process is keeping which port occupied.

Posted in Linux | 1 Comment »