1.use lisof command
lisof
: list all open files, is a linux command
An open file may be regular file, a directory, a block special file, a charactor special file, an executing text reference, a library, a stream or a network file(Internet socket, NFS file or UNIX domain socket.) A special file or all the files in a file system may be selected by path.
//compitable with macOS Sierra 10.12.4
#lsof -i -n -P | grep
Eudic 1229 lewis 16u IPv4 0x7348b30605dcd4a7 0t0 TCP *:32094 (LISTEN)
Eudic 1229 lewis 34u IPv4 0x7348b30605dcd4a7 0t0 TCP *:32094 (LISTEN)
Shadowsoc 1521 lewis 4u IPv4 0x7348b306022769bf 0t0 TCP *:8090 (LISTEN)
Shadowsoc 1521 lewis 8u IPv4 0x7348b30606fba9bf 0t0 TCP 127.0.0.1:1080 (LISTEN)
java 3762 lewis 60u IPv6 0x7348b3060ebc2957 0t0 TCP *:8009 (LISTEN)
java 3762 lewis 76u IPv6 0x7348b30602273417 0t0 TCP 127.0.0.1:8005 (LISTEN)
studio 3802 lewis 181u IPv4 0x7348b30610e202b7 0t0 TCP 127.0.0.1:6943 (LISTEN)
studio 3802 lewis 365u IPv4 0x7348b306040374a7 0t0 TCP 127.0.0.1:63343 (LISTEN)
adb 3810 lewis 6u IPv4 0x7348b30610fb10c7 0t0 TCP 127.0.0.1:5037 (LISTEN)
QQ 4018 lewis 33u IPv4 0x7348b30612cd30c7 0t0 TCP 127.0.0.1:4300 (LISTEN)
QQ 4018 lewis 34u IPv4 0x7348b3061159dbaf 0t0 TCP 127.0.0.1:4301 (LISTEN)
java 4143 lewis 58u IPv6 0x7348b3060c0bb417 0t0 TCP *:8080 (LISTEN)
java 4143 lewis 74u IPv6 0x7348b30602273e97 0t0 TCP 10.203.6.187:8005 (LISTEN)