実現したいこと
$ sudo netstat -ntpl
Linuxで上記のようにnetstatコマンドを利用して実現していることをMacOSX Mavericksでも実現する
MacOSX Mavericksでnetstatコマンドを利用してListenしているポートを調べるには、-l ではなく -L を利用する。
lsofコマンドを利用する
$ sudo lsof -nP -iTCP | grep LISTEN
- MacOSX Mavericksに標準で導入されているnetstatコマンドは、Linuxに標準で導入されているnetstatコマンドとは、若干仕様が違うため lsofコマンドを利用します。
$ netstat -h
netstat: illegal option -- h
Usage: netstat [-AaLlnW] [-f address_family | -p protocol]
netstat [-gilns] [-f address_family]
netstat -i | -I interface [-w wait] [-abdgRt]
netstat -s [-s] [-f address_family | -p protocol] [-w wait]
netstat -i | -I interface -s [-f address_family | -p protocol]
netstat -m [-m]
netstat -r [-Aaln] [-f address_family]
netstat -rs [-s]
$
$ man netstat
〜 snip 〜
-L Show the size of the various listen queues. The first count shows the number of unaccepted connections. The second count shows the amount of unaccepted incomplete con-
nections. The third count is the maximum number of queued connections.
-l Print full IPv6 address.
〜 snip 〜