lsof and listening ports
sudo lsof -iTCP -sTCP:LISTEN
sudo lsof -iTCP -sTCP:LISTEN -P
sudo lsof -iTCP -sTCP:LISTEN -P -n
sudo lsof -iTCP -sTCP:LISTEN -n
All return the same 32 entries (... | wc -l
) on my heavily used Lion MBP.
-P -n
prevents lsof
from doing name resolution, and it doesn't block. Missing either one of these, it can be very slow.
For UDP: sudo lsof -iUDP -P -n | egrep -v '(127|::1)'
. Without -n
and -P
, it takes a long time.
Reminder: This does not include firewall settings.