Finding the PID for a Port in UNIX/Linux

When troubleshooting in an enterprise where many individuals and applications are involved, rogue processes can be problematic. A nice tool to help identify what may be happening in your environment is included with most, if not all, UNIX/Linux distributions. If you are finding you need help identifying programs using specific ports, Netstat is a great tool to use.

Use Netstat with the following switches:

 netstat -pantu  
 -p (display PID/Program name for sockets)  
 -a (display all sockets)  
 -n (don't resolve names)  
 -t (tcp)  
 -u (udp)   

Then grep for the port you’re interested in. It will show the PID and a brief name of the process or processes

 netstat -pantu | grep 8001  


Then grep on the PID numbers to find out exactly what these processes are

 ps -ef | grep 25658  


 ps -ef | grep 6319  


Looks like the WebLogic SOA and WebLogic AdminServer are the culprits in this case