Networking
cancel
Showing results for 
Search instead for 
Did you mean: 

How to find which process owns a TCP port

MasthanD
Occasional Contributor

How to find which process owns a TCP port

Hi All,

Could you please let me know how can I find which process is listening on given TCP port number?

If I run the command "netstat -na |grep <port number>" hen it showing that some process is listening but it is not showing who is listening.

example out put :

 

bash-4.3$ netstat -an |grep 2000
tcp 0 0 127.0.0.1.2000 *.* LISTEN
bash-4.3$

In the above example it is not clear which process is listening on TCP port 2000. Could you please let me know how can I find it?

Thanks,

Masthan

4 REPLIES
Torsten.
Acclaimed Contributor

Re: How to find which process owns a TCP port

You don't tell your OS.

However, try

lsof -i :80

Port 80, for example.


Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
MasthanD
Occasional Contributor

Re: How to find which process owns a TCP port

my appology, my os is HPUX 11.31.

Can't we get the same info using netstat command?

Torsten.
Acclaimed Contributor

Re: How to find which process owns a TCP port

why not installing lsof?

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Bill Hassell
Honored Contributor

Re: How to find which process owns a TCP port

netstat does not track down the process(es) that have a port open.

lsof is a required tool for any sysadmin as it not only tracks port usage, it tracks open files and directories.
HP-UX provides fuser for open files but is not very complete at tracking usage.



Bill Hassell, sysadmin