lsof
List the TCP server sockets in the LISTEN state:
sudo lsof -iTCP -sTCP:LISTEN -P -n
or
sudo lsof -i -P -n | grep LISTEN
List the TCP server sockets in the LISTEN state:
sudo lsof -iTCP -sTCP:LISTEN -P -n
or
sudo lsof -i -P -n | grep LISTEN