To get a quick idea of what ports you have open on your local box, you can use nmap.
~ jhaddad$ nmap localhost Starting Nmap 5.00 ( http://nmap.org ) at 2010-01-05 11:06 PST Interesting ports on localhost (127.0.0.1): Not shown: 499 closed ports, 492 filtered ports PORT STATE SERVICE 80/tcp open http 88/tcp open kerberos-sec 548/tcp open afp 631/tcp open ipp 3306/tcp open mysql 3325/tcp open unknown 5900/tcp open vnc 9000/tcp open cslistener 10000/tcp open snet-sensor-mgmt
For more detailed information, try netstat:
You’ll get a breakdown of every socket open on your machine - useful for figuring out who’s connected and from where.
The OSX version of netstat lacks a few options - such as the useful ‘-p’ option to display the process id (PID) - which can be useful combined with kill to get rid of unwanted connections - for instance,an SSH tunnel accidentally left open.