On Tue, 30 May 2000, Rodent of Unusual Size wrote:

> Argh..  I used to know this (I think), but now I've forgotten..
> 
> How can I turn a port number from netstat's output into a PID?
> I want to find out what non-obvious thing is listening on a
> particular port..

With more recent versions of the netstat command, you can use the -p
option to find out the process id associated with the socket. I would
give an example but the output is messy if you don't have a display
that's about 132 chars wide...

If you have an older version of netstat which does not do this, you should
be able to poke through the output of lsof to figure it out.

For example, if you wanted to find out which processes were bound to port
80 on your machine:

[root@martin martin]# lsof |grep www
httpd       590 root   16u  IPv4    827    TCP *:www   (LISTEN)
httpd     29691 root   16u  IPv4    827    TCP *:www   (LISTEN)
httpd     29692 root   16u  IPv4    827    TCP *:www   (LISTEN)
httpd     29693 root   16u  IPv4    827    TCP *:www   (LISTEN)
[snippage]

-- 
Derek Martin
System Administrator
Mission Critical Linux
[EMAIL PROTECTED] 


**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to