'Linux/OSX: Find Out What Network Ports Are in Use'
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:
netstat -an
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.
If you found this post helpful, please consider sharing to your network. I'm also available to help you be successful with your distributed systems! Please reach out if you're interested in working with me, and I'll be happy to schedule a free one-hour consultation.