Operating System - HP-UX
1834346 Members
1856 Online
110066 Solutions
New Discussion

Finding the port number information

 
SOLVED
Go to solution
phani_3
Occasional Advisor

Finding the port number information

Hi,

How to find out how many processes are getting served by a particular port number & related information..Is there any command which will give the above information, apart from 'rpcinfo'..Is the command 'lsof' will provide this information..if yes please provide me the lsof script & the options to use it.
if anybody is free..please provide me the solution asap...waiting for your prompt reply. :)

Thank You,
Best Regards,
Phani Varma P.
7 REPLIES 7
Sanjay_6
Honored Contributor

Re: Finding the port number information

Hi,

Have you tried "netstat -an". Grep for the port number you want.

Hope this helps.

Regds
Helen French
Honored Contributor

Re: Finding the port number information

Yes, you can use lsof for getting those information. It's a free download from here:

http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.69/
Life is a promise, fulfill it!
phani_3
Occasional Advisor

Re: Finding the port number information

Hi Wilson

Thanks for your information..Can you give me the particular options/syntax to use lsof so that i can get the desired output.

Regards,
Phani
Vijaya Kumar_3
Respected Contributor

Re: Finding the port number information

lsof -i
command will give you all ports and their associated process IDs.

you can do a grep.

lsof -i | grep 389

You can also use lsof with -k option to kill.

-Vijay
Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
Helen French
Honored Contributor
Solution

Re: Finding the port number information

You can read the help file for lsof for all available optoins. Here are some of them:

# lsof -c your_command (will tell you all process that opened with 'your_command')

# lsof -p PID (open files from a process PID)
# lsof -u UID/user_name (open files for a user login)

# lsof -i tcp:200 (process list on the socket by tcp protocol)
Life is a promise, fulfill it!
Helen French
Honored Contributor

Re: Finding the port number information

This complete lsof FAQ will be useful too:

ftp://vic.cc.purdue.edu/pub/tools/unix/lsof/FAQ/
Life is a promise, fulfill it!
KapilRaj
Honored Contributor

Re: Finding the port number information

lsof -i tcp:?? where ??=portnumber

e.g.

lsof -i tcp:80
lsof -i tcp:8080

Kaps
Nothing is impossible