In the world of Linux, you could use netstat
to list all ports that are open on your system. I tend to use the following in Linux:
netstat -aep | grep ':\*'
However, netstat
in Mac OS X behaves extremely differently. To be able to list open ports on Mac OS X, you could use something along the lines of:
sudo lsof -i -P | grep -i "listen"
For example:
localhost:~$ sudo lsof -i -P | grep -i "listen" launchd 1 root 27u IPv6 0xf38ca75ebb725cfd 0t0 TCP localhost:631 (LISTEN) launchd 1 root 28u IPv4 0xf38ca75ebb726c1d 0t0 TCP localhost:631 (LISTEN) launchd 1 root 30u IPv6 0xf38ca75ebb72591d 0t0 TCP *:22 (LISTEN) launchd 1 root 31u IPv4 0xf38ca75ebb7264cd 0t0 TCP *:22 (LISTEN) polard 79 root 6u IPv4 0xf38ca75ebdb15c1d 0t0 TCP localhost:49152 (LISTEN) ...