Skip to content

Instantly share code, notes, and snippets.

@iguoli
Last active January 5, 2019 06:23
Show Gist options
  • Save iguoli/22de63ffba24d5f8fd1f6a215718084e to your computer and use it in GitHub Desktop.
Save iguoli/22de63ffba24d5f8fd1f6a215718084e to your computer and use it in GitHub Desktop.
查看系统中监听端口列表

MacOS

lsof -Pn -i4 | grep LISTEN

其中,-P表示显示IP而不是hostname, -n表示显示端口号而不是端口对应的程序名。-i用于匹配对应选项的网络地址,-i4表示匹配IPV4相关网络地址。

Linux

netstat -tupln
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment