Reputation: 611
In Ubuntu, to see the listening process I used to do the following command netstat -pant I would get something similar to this
What is the equivalent command with the Mac ?
Upvotes: 6
Views: 8013
Reputation: 14010
(from this answer)
To show the processes, you would use netstat -vanp tcp
. This doesn't translate the PIDs to process names, but you could do an awk
using ps
to translate them. Alternatively, you could go straight to sudo lsof -i tcp
and get a slightly different layout that maps ports to named processes.
Here's an example (newlines added for readability):
netstat -vanp tcp |
awk 'BEGIN { l=0 }
{ if (l == 0) { print $0 }
else if (l == 1) { print $0, "process" }
else { "ps -o comm " $9 "| tail -1" | getline line;
print $0, line }
l++; }'
If you want UDP results instead, just specify udp
instead of tcp
.
Upvotes: 10