V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cuijiudai
V2EX  ›  macOS

mac上如何查看某端口号被哪些程序占用?

  •  
  •   cuijiudai · 2012-10-22 16:50:35 +08:00 · 76077 次点击
    这是一个创建于 4175 天前的主题,其中的信息可能已经有所发展或是发生改变。
    比如127.0.0.1:8087,如何查看哪个进程占用了8087
    6 条回复    1970-01-01 08:00:00 +08:00
    yangg
        1
    yangg  
       2012-10-22 16:53:16 +08:00
    lsof -i :80
    bearice
        2
    bearice  
       2012-10-22 17:02:01 +08:00   ❤️ 8
    sudo lsof -n -P| grep :8087
    gavingeng
        3
    gavingeng  
       2012-10-23 00:29:14 +08:00   ❤️ 1
    nc -v -w 2 127.0.0.1 8087
    leecade
        4
    leecade  
       2012-10-23 01:34:11 +08:00
    lsof -i tcp:8087
    leecade
        5
    leecade  
       2012-10-23 01:42:52 +08:00   ❤️ 2
    better 在 bash 自定义下

    # belongs to port
    # usage: "port 8000"
    function port() { lsof -i tcp:$1 }

    # all open ports
    # usage: "ports"
    function ports() { lsof -Pni4 | grep LISTEN }
    xiaket
        6
    xiaket  
       2012-10-23 14:16:48 +08:00
    [xiaket@rondo:~]alias nettop
    alias nettop='nettop -nm tcp'
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3424 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:14 · PVG 19:14 · LAX 04:14 · JFK 07:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.