os x and netstat

Jason Joines joines at okstate.edu
Mon Nov 12 12:42:29 PST 2007


Bill Campbell wrote:
> On Mon, Nov 12, 2007, Jason Joines wrote:
>>    I'm a Linux sysadmin but just took a job where I inherited a bunch 
>> of os x boxes.  One of the differences I've noticed is that netstat 
>> doesn't display all of the applications listening on network ports.  It 
>> does display some and I'm not sure how it picks which ones to display. 
>> Does anyone know if this is just an os x thing or do the BSD's do this 
>> as well?
> 
> First, are you running this as root?
> 
> I often use ``lsof -n -i | grep LISTEN'' to see this on OS X,
> Linux, and FreeBSD systems as it gives information on the process
> listening on the ports.
> 
> Bill
> --
> INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
> URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
> FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
> 
> Never chastise a Windows user...just smile at them kindly as you would a
> disadvantaged child. WBM


     Yep, it was as root.  lsof did show at least one of the processes 
that netstat did not.  Almost everything shown by grepping LISTEN from 
lsof is not shown via netstat.  It looks like netstat is only showing 
ESTABLISHED connections where tcp is concerned.
     Ah found it.  Just needed another option, -a, netstat -a -n -f inet 
does the trick.  Guess I've gotten so used to the way Linux and GNU 
utilities work that I've forgotten to read my man pages carefully.  Via 
the man page I'd say that's the way BSD's work in general.


Jason
===========




More information about the Linux-users mailing list