iproute2 之 ss 指令
iproute2 之 ss 指令
ss 是 socket stat 的简写

帮助文本

plainUsage: ss [OPTIONS]
       ss [OPTIONS] [FILTER]

   -h, --help          显示本帮助文本
   -V, --version       显示版本信息文本
   -n, --numeric       不解析服务名称
   -r, --resolve       解析主机名
   -a, --all           显示所有套接字
   -l, --listening     只显示监听状态的套接字
   -o, --options       显示 timer 信息
   -e, --extended      显示更详细的套接字信息
   -m, --memory        显示套接字使用的内存
   -p, --processes     显示套接字关联的进程
   -i, --info          显示 TCP 套接字的信息
       --tipcinfo      显示 tipc 套接字的信息
   -s, --summary       显示套接字概览
       --tos           显示 tos 和 priority 信息
       --cgroup        显示 cgroup 信息
   -b, --bpf           显示 bpf 过滤器信息
   -E, --events        显示被销毁的套接字
   -Z, --context       display process SELinux security contexts
   -z, --contexts      display process and socket SELinux security contexts
   -N, --net           使用指定的网络命名空间
   -4, --ipv4          只显示 IPv4 套接字
   -6, --ipv6          只显示 IPv6 套接字
   -0, --packet        display PACKET sockets
   -t, --tcp           只显示 TCP 套接字
   -M, --mptcp         只显示 MPTCP 套接字
   -S, --sctp          只显示 SCTP 套接字
   -u, --udp           只显示 UDP 套接字
   -d, --dccp          只显示 DCCP 套接字
   -w, --raw           只显示 RAW 套接字
   -x, --unix          只显示 Unix domain 套接字
       --tipc          只显示 TIPC 套接字
       --vsock         只显示 vsock 套接字
   -f, --family=FAMILY 显示组合家族的套接字(其实就是上面选项的组合),家族可组合项目:{inet|inet6|link|unix|netlink|vsock|tipc|xdp|help}
   -K, --kill          强制关闭套接字并显示哪些被关闭了
   -H, --no-header     不显示表头
   -O, --oneline       数据显示成一行
       --inet-sockopt  show various inet socket options
   -A, --query=QUERY   QUERY := {all|inet|tcp|mptcp|udp|raw|unix|unix_dgram|unix_stream|unix_seqpacket|packet|netlink|vsock_stream|vsock_dgram|tipc}[,QUERY]
       --socket=QUERY  QUERY := {all|inet|tcp|mptcp|udp|raw|unix|unix_dgram|unix_stream|unix_seqpacket|packet|netlink|vsock_stream|vsock_dgram|tipc}[,QUERY]
   -D, --diag=FILE     将 TCP 套接字的信息转储到指定文件
   -F, --filter=FILE   read filter information from FILE
       FILTER := [ state STATE-FILTER ] [ EXPRESSION ]
       STATE-FILTER := {all|connected|synchronized|bucket|big|TCP-STATES}
         TCP-STATES := {established|syn-sent|syn-recv|fin-wait-{1,2}|time-wait|closed|close-wait|last-ack|listening|closing}
          connected := {established|syn-sent|syn-recv|fin-wait-{1,2}|time-wait|close-wait|last-ack|closing}
       synchronized := {established|syn-recv|fin-wait-{1,2}|time-wait|close-wait|last-ack|closing}
             bucket := {syn-recv|time-wait}
                big := {established|syn-sent|fin-wait-{1,2}|closed|close-wait|last-ack|listening|closing}

显示处于监听状态的 TCP 套接字并显示其关联进程

plainroot@vm1:~# ss -tlp
State              Recv-Q             Send-Q                Local Address:Port                  Peer Address:Port             Process
LISTEN             0                  20                    127.0.0.1:25                        0.0.0.0:*                     users:(("exim4",pid=23934,fd=4))
LISTEN             0                  511                   0.0.0.0:80                          0.0.0.0:*                     users:(("openresty",pid=47388,fd=6),("openresty",pid=47387,fd=6),("openresty",pid=32445,fd=6))
LISTEN             0                  511                   0.0.0.0:443                         0.0.0.0:*                     users:(("openresty",pid=47388,fd=11),("openresty",pid=47387,fd=11),("openresty",pid=32445,fd=11))
LISTEN             0                  128                   0.0.0.0:22                          0.0.0.0:*                     users:(("sshd",pid=19478,fd=3))

显示处于监听状态的 IPv6 UDP 套接字并显示其关联进程

plainroot@us5:~# ss -lup6
State              Recv-Q             Send-Q                Local Address:Port                  Peer Address:Port             Process
UNCONN             0                  0                     [::]:36570                          [::]:*                        users:(("zerotier-one",pid=192921,fd=24))
UNCONN             0                  0                     [::]:9993                           [::]:*                        users:(("zerotier-one",pid=192921,fd=20))
UNCONN             0                  0                     [::1]:323                           [::]:*                        users:(("chronyd",pid=20966,fd=6))
作者
ragnaroks
发布时间
2022-07-18
创作协议