System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the process name or process id of the opened ports

SOLVED
Go to solution
senthil_kumar_2
Regular Advisor

How to find the process name or process id of the opened ports

Hi All,

We can find all opened ports using the command "netstat".

Now i want to know the process name or process id of those opened ports.
9 REPLIES
Johnson Punniyalingam
Honored Contributor
Solution

Re: How to find the process name or process id of the opened ports

Using "lsof" command you can find that

if you have installed "lsof"

see below example:-

take note 80 --> port

# lsof -i :80

COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
apache2 10437 root 3u IPv6 22890556 TCP *:www (LISTEN)
apache2 10438 www-data 3u IPv6 22890556 TCP *:www (LISTEN)
apache2 10439 www-data 3u IPv6 22890556 TCP *:www (LISTEN)
apache2 10440 www-data 3u IPv6 22890556 TCP *:www (LISTEN)
apache2 10441 www-data 3u IPv6 22890556 TCP *:www (LISTEN)
apache2 10442 www-data 3u IPv6 22890556 TCP *:www (LISTEN)
apache2 25966 www-data 3u IPv6 22890556 TCP *:www (LISTEN)
apache2 25968 www-data 3u IPv6 22890556 TCP *:www (LISTEN)

Thanks,
Johnson
Problems are common to all, but attitude makes the difference
Johnson Punniyalingam
Honored Contributor

Re: How to find the process name or process id of the opened ports

man lsof

more infromation
Problems are common to all, but attitude makes the difference
R.K. #
Honored Contributor

Re: How to find the process name or process id of the opened ports

Hi Senthil,

And Lsof utility can be downloaded from:

http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.82/


Regds..
Don't fix that what ain't broke
senthil_kumar_2
Regular Advisor

Re: How to find the process name or process id of the opened ports

Hi All,

I have installed "lsof" and i am able to see the man page also.

but i am not able to run.

Ex:

# lsof -i :22
sh: lsof: not found.


So in which location lsof has been installed?

sujit kumar singh
Honored Contributor

Re: How to find the process name or process id of the opened ports

Hi

/usr/local/bin/lsof

you can do

whereis lsof

regards
sujit
Steven Schweda
Honored Contributor

Re: How to find the process name or process id of the opened ports

> I have installed "lsof" [...]

> So in which location lsof has been
> installed?

If _you_ installed it (using commands which
only _you_ can see), how should any other
non-psychic person know where it went? Or
what your PATH variable is?
Raj D.
Honored Contributor

Re: How to find the process name or process id of the opened ports

Senthil,

>
# lsof -i :22
sh: lsof: not found.


Being hp-ux admin, at least you should have tried the find command, to find lsof:

# find / -name lsof -print
And_it_will tell_you_the_answer.



- Btw : with netstat to see the wait , open and established connections, use:
# netstat -n
# to see all established connections:
# netstat -n | grep EST

Hth,
" If u think u can , If u think u cannot , - You are always Right . "
James R. Ferguson
Acclaimed Contributor

Re: How to find the process name or process id of the opened ports

Hi Senthil:

> I have installed "lsof" and i am able to see the man page also. but i am not able to run

Software from the HP-UX Porting Centre is installed in '/usr/local/bin'. This directory is (by default) not in root't PATH so you won't be able to simply run 'lsof' by typing 'lsof' at the prompt.

You can use an absolute path to run ('/usr/local/bin/lsof' or add '/usr/local/bin' to your PATH.

Regards!

...JRF...
senthil_kumar_2
Regular Advisor

Re: How to find the process name or process id of the opened ports

I am closing this thread.