What is the Mac equivalent of TCPView or CurrPorts? I've never used Mac before, so I'm clueless.

alt text

link|improve this question

feedback

migrated from stackoverflow.com Dec 10 '10 at 5:20

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 1 down vote accepted

both netstat and lsof will do this:

$ netstat -an | grep -i "listen"
tcp4       0      0  *.88                   *.*                    LISTEN
tcp6       0      0  *.88                   *.*                    LISTEN
tcp4       0      0  127.0.0.1.29746        *.*                    LISTEN
tcp46      0      0  *.5900                 *.*                    LISTEN
tcp4       0      0  *.22                   *.*                    LISTEN
tcp6       0      0  *.22                   *.*                    LISTEN
tcp4       0      0  *.548                  *.*                    LISTEN
tcp6       0      0  *.548                  *.*                    LISTEN
tcp4       0      0  127.0.0.1.631          *.*                    LISTEN
tcp6       0      0  ::1.631                *.*                    LISTEN

$ sudo lsof -i -P | grep -i "listen"
launchd       1           root   18u  IPv6 0x08871e20      0t0    TCP localhost:631 (LISTEN)
launchd       1           root   19u  IPv4 0x08876b4c      0t0    TCP localhost:631 (LISTEN)
launchd       1           root   69u  IPv6 0x08871bb0      0t0    TCP *:548 (LISTEN)
launchd       1           root   71u  IPv4 0x08876740      0t0    TCP *:548 (LISTEN)
launchd       1           root   74u  IPv6 0x08871940      0t0    TCP *:22 (LISTEN)
launchd       1           root   75u  IPv4 0x08876334      0t0    TCP *:22 (LISTEN)
krb5kdc      34           root   11u  IPv6 0x08870830      0t0    TCP *:88 (LISTEN)
krb5kdc      34           root   14u  IPv4 0x090ea6b0      0t0    TCP *:88 (LISTEN)
AppleVNCS   205           brad    9u  IPv6 0x088716d0      0t0    TCP *:5900 (LISTEN)
cvpnd     20863         nobody    6u  IPv4 0x091072a4      0t0    TCP localhost:29746 (LISTEN)

If you're command-line averse, you can also just port scan yourself (run Network Utility, go to the Port Scan tab, type in localhost and hit "Scan").

link|improve this answer
feedback

You can use the command line tool netstat to get that information.

link|improve this answer
How do you get netstat to show the number circled in red in my screenshot above? – JoJo Oct 11 '10 at 20:44
If I understand the CurrPorts display, that's the remote TCP port number; netstat -an would show it something like this: tcp4 0 0 172.0.0.1.56665 127.0.0.1.56664 ESTABLISHED – Gordon Davisson Oct 11 '10 at 21:01
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.