Operating System - HP-UX
1824881 Members
3899 Online
109675 Solutions
New Discussion

How to know process id of a listening port

 
jeisma
New Member

How to know process id of a listening port

Hi,

I want to kill the process that's listening on a port.

From several posts, the recommendations are use lsof. Unfortunately, I am not in a position to install anything.

netstat is one option, however, the flags recommended don't apply to our ux version (HP-UX HPDev B.11.31 U ia64) .

So, how would you know the owner of a given port?

 

Thanks!

3 REPLIES 3
Steven Schweda
Honored Contributor

Re: How to know process id of a listening port

> I want to kill the process that's listening on a port.

   Which "a port"?

> From several posts, the recommendations are use lsof. [...]

   Yup.

> [...] Unfortunately, I am not in a position to install anything.

   Because?  No foreign software any place, or what?

> netstat is one option, however, the flags recommended [...]

   Which "the flags", "recommended" by whom?  If you're looking at some
GNU/Linux program, then I wouldn't be amazed if the HP-UX program of the
same name were different/older/worse.

> So, how would you know the owner of a given port?

   I'd install "lsof":

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

   But you might need to run it as "root" to get the results you seek.
For example:

dyi# uname -a
HP-UX dyi B.11.31 U ia64 4235313755 unlimited-user license

dyi# su - sms
dyi $ /usr/local/src/lsof/lsof-4.89/lsof -i :22
dyi $ logout
logout root
dyi# /usr/local/src/lsof/lsof-4.89/lsof -i :22
COMMAND  PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
sshd     889 root    4u  IPv6 0xe00000014aa9e100      0t0  TCP *:22 (LISTEN)
sshd     889 root    5u  IPv4 0xe00000014a36ad00      0t0  TCP *:22 (LISTEN)

dyi# ps -ef | grep ' 889 '
    root   889     1  0 21:08:41 ?         0:00 /opt/ssh/sbin/sshd

Re: How to know process id of a listening port

Have a look at the pfiles command - that may help.


I am an HPE Employee
Accept or Kudo
ranganath ramachandra
Esteemed Contributor

Re: How to know process id of a listening port

The fuser(1M) command should help.

  -k   Send the SIGKILL signal to each process using each file.
       You must have appropriate privileges to kill processes that
       you do not own.

Ports (in place of file paths) can be specified with port number and protocol (tcp/udp) separated by a slash ('/'). So:

fuser -k 22/tcp

could kill sshd.

 
--
ranga
hp-ux 11i v3[i work for hpe]

Accept or Kudo