V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
wind3110991
V2EX  ›  Linux

话说在 MAC OS 下如何用 netstat 查看 Listen 状态啊, netstat -tunlp 这个命令话说好像不行

  •  
  •   wind3110991 · 2015-03-19 01:42:57 +08:00 · 15351 次点击
    这是一个创建于 3325 天前的主题,其中的信息可能已经有所发展或是发生改变。

    google下,大神说一个用netstat -anL
    但是这个无法查看连接的协议
    我部机输出是:
    Current listen queue sizes (qlen/incqlen/maxqlen)
    Listen Local Address

    0/0/128 *.80

    0/0/128 ::1.25035

    0/0/128 127.0.0.1.25035

    0/0/50 *.3306

    0/0/128 *.88

    0/0/128 *.88

    0/0/128 127.0.0.1.631

    0/0/128 ::1.631

    0/0/128 *.445

    0/0/128 *.445

    0/0/128 *.548

    0/0/128 *.548

    另外一个大神说用 lsof -ni | grep LISTEN
    输出:
    GitHub 497 pro 15u IPv4 0xa6e56565db9d8793 0t0 TCP 127.0.0.1:25035 (LISTEN)
    GitHub 497 pro 16u IPv6 0xa6e56565d61219b3 0t0 TCP [::1]:25035 (LISTEN)

    有没有更好的方法?

    可以输出
    netstat -tunlp的效果
    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

    tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2493/portmap

    tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2776/cupsd

    tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2808/sendmail: acce
    tcp 0 0 0.0.0.0:1020 0.0.0.0:* LISTEN 2534/rpc.statd

    tcp 0 0 :::3306 :::* LISTEN 15681/mysqld

    tcp 0 0 :::22 :::* LISTEN 2767/sshd

    6 条回复    2015-03-20 11:53:36 +08:00
    sunjourney
        1
    sunjourney  
       2015-03-19 07:56:44 +08:00   ❤️ 1
    netstat -a | grep LISTEN
    dorentus
        2
    dorentus  
       2015-03-19 14:27:42 +08:00
    /usr/sbin/lsof -i
    miterleo
        3
    miterleo  
       2015-03-19 15:25:43 +08:00
    lsof -iTCP -sTCP:LISTEN -nP
    wind3110991
        4
    wind3110991  
    OP
       2015-03-19 16:56:37 +08:00
    @sunjourney 你的这个方法稍微好一些~~谢谢!
    beordle
        5
    beordle  
       2015-03-20 03:54:33 +08:00
    楼主最近刷屏节奏。。yuki头像。。每次都会手贱点进来。。
    wind3110991
        6
    wind3110991  
    OP
       2015-03-20 11:53:36 +08:00
    @beordle 我错了嘛~么么大
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3259 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 12:39 · PVG 20:39 · LAX 05:39 · JFK 08:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.