How to know PID responsible for network connection/listen?

Chuck Robey chuckr at chuckr.org
Sat Nov 17 17:55:05 PST 2007


Tino Engel wrote:
> Matthias Apitz schrieb:
>> El día Thursday, November 15, 2007 a las 11:20:30AM -0800, Yuri escribió:
>>
>>  
>>> 'netstat -a' gives me the listing of network connection/listening 
>>> records.
>>> But there's no link to the process id that opened it.
>>> With lots of processes this can be a significant problem to figure 
>>> out who
>>> opened which connection.
>>>     
>>
>> For example, for the port 25 you see it with:
>>
>> # lsof -P | fgrep :25
>> sendmail  6462  root    3u    IPv4 0xc5c3ecb0        0t0     TCP 
>> localhost:25 (LISTEN)
>>
>> i.e. the PID is 6462
>>
>> HIH
>>
>>     matthias
>>   
> ps -Al show the parent PID of each process.

I just moved from Linux, where the netstat does supply the info you're 
asking, and it took me a little time to find out that sockstat is where 
the info is, in FreeBSD.

Try sockstat.

> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to 
> "freebsd-questions-unsubscribe at freebsd.org"



More information about the freebsd-questions mailing list