[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: network administration question



Not sure this is what you want, but lsof in the ports will show you
the process name and PID that is associated with a port number.

So lsof -i shows you:

COMMAND   PID   USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
sshd    17767   root    3u  IPv6 0xe096c500      0t0  TCP *:ssh (LISTEN)

(Forgive any bad word wrap)

Mike

On Sat, Feb 16, 2002 at 12:32:17AM +0000, experte wrote:
> Hi!
> 
> I'd like to know how I can get the PID of a running socket.
> netstat(1) would give me the port-number and the stats but 
> how can I map this to an pid? Maybe I'm missing something 
> obvious (again:-) but ps(1) - on the other side - won't show me 
> ip or port-number. (I heard some rumors about a -p flag for 
> netstat on some *nixes to get the pid but OpenBSDs netstat
> uses this flag for protocols and seems to have no equivalent).
> Ok, I could use lsof from the ports but I think there should 
> be a native solution possible?
> 
> Thanks in advance 
> 
> Alf
> 
> P.S.: Horrible English, isn't it;)

-- 
Michael Sullenszino    /----------------------------------------\
mike@sullenszino.org  ||  Powered by OpenBSD (www.OpenBSD.org)  ||
www.sullenszino.org   ||   & Debian GNU/Linux (www.debian.org)  ||
206.722.6539           \----------------------------------------/