List processes listening on TCP ports on Mac OS X using lsof

lsof -i | grep LISTEN | grep "TCP \*:" | sort

Or to find out what processes have open connections use

lsof -i | grep ESTABLISHED | sort

Nothing ground breaking, but useful. netstat gives you similar info, but doesn’t include the process.


Set DirectoryService debug level

Apple’s document on Extending and Troubleshooting Directory Services has a lot of good info.

One correction though is that the debug level must be an integer.
sudo defaults write /Library/Preferences/DirectoryService/DirectoryServiceDebug "Debug Logging Priority Level" -integer 2

I’ve notified Apple, so this may be fixed by the time you read this.

Update: That link is dead. Here is an article that offers some similar information.