Operating System - HP-UX
1753277 Members
4887 Online
108792 Solutions
New Discussion юеВ

Re: Ports - How to know which application is using certain ports

 
SOLVED
Go to solution
haneps
Occasional Advisor

Ports - How to know which application is using certain ports

I have a HP-UX 11.11 machine and I would like to know whether a port is belong to which application/daemon currently running.

I know I can use netstat -antup in linux, but can this be done in HP-UX?

Thanks.
7 REPLIES 7
likid0
Honored Contributor
Solution

Re: Ports - How to know which application is using certain ports

You can use lsof.

You can dowload it from:

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

An example:

lsof -i tcp:80

this gives you the proccess runing on that port, have a look at the man page for all the ops
Windows?, no thanks
Matti_Kurkela
Honored Contributor

Re: Ports - How to know which application is using certain ports

HP-UX netstat does not have the -p option.

You'll need to install the free open-source "lsof" utility and use it to identify the programs using each port. It is available as a .depot in the HP-UX Porting Archive.

http://hpux.asknet.de/hppd/hpux/Sysadmin/lsof-4.81/

lsof uses a more flexible syntax. To find out the name of the process using a single known port and protocol (TCP or UDP), you can use something like this:

# lsof -i tcp:22
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
sshd 3858 root 3u IPv4 7908 TCP *:ssh (LISTEN)

I.e. the process using the TCP port 22 was named "sshd", process ID 3858.

You can also list all the network connections at once, with just "lsof -i". There are many other qualifiers you can use to restrict lsof output as necessary.

MK
MK
haneps
Occasional Advisor

Re: Ports - How to know which application is using certain ports

Thank you all for the brilliant suggestion!

But if lsof is not possible to be installed in my system. Can I use any other method?

Thanks

Re: Ports - How to know which application is using certain ports

well if you have glance installed you can go to the "open files" page for a given process by pressing "F" and entering a processes pid.

otherwise no, there is no easy way short of writing code to do it (and in that case you might as well install lsof)

In 11iv3 we have the "pfiles" command built in which will do this, but nothing in netstat.

Rememeber 11.11 is now a 9 year old OS, so don't be too hard on it - compare it to Windows 2000, Solaris 7/8 and AIX 4, not too a modern Linux distro.

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Emil Velez
Honored Contributor

Re: Ports - How to know which application is using certain ports


netstat -a will show you ports in use but only label the well known services

haneps
Occasional Advisor

Re: Ports - How to know which application is using certain ports

Thank you all for the help!
Taifur
Respected Contributor

Re: Ports - How to know which application is using certain ports

Hi haneps

You can check by netstat -a | more


Rgds,
Taifur