Monday 31 August 2009

Listing open ports on OSX

Another day, another thing learned.

I've only been using OSX for about a year (no way in hell I'm ever going back to Winblows) and so I still consider myself quite the OSX virgin. Also my Unix/Linux or Unix-like experience isn't that extensive either. I've only played around a bit with Solaris and Ubuntu and I know just enough to find my way around and support my development work, but that is where it stops.

So for listing open ports I always farted about a bit with netstat and grep. So imagine my surprise when I tried to list the open ports on my Mac in my tried and tested way. Just let me say it wasn't quite what I'd expected. But it seems that there is nothing that a bit of Googling won't solve and so I quickly arrived at the lsof command (which isn't solely available on OSX by the way) and now I use the following command to list open ports:

sudo lsof -i -P | grep -i "listen"

During my Googling I also came across this extremely useful site: commandlinefu.com

No comments:

Post a Comment