大话命令之--ss

[root@CentOS68 ~]# ss -t -a

LISTEN 0 100 127.0.0.1:smtp *:*

UNCONN 0 0 :::928 :::*

LISTEN 0 128 *:sunrpc *:*

    -w:裸套接字相关

UNCONN 0 0 127.0.0.1:972 *:*

    -a:所有

1 格式

ESTAB 0 64 192.168.29.68:ssh 192.168.29.1:50541

LISTEN 0 100 ::1:smtp :::*

UNCONN 0 0 *:bootpc *:*

    -n:数字格式

[root@CentOS68 ~]# ss -l

LISTEN 0 128 *:ssh *:*

LISTEN 0 128 127.0.0.1:ipp *:* users:(("cupsd",1679,7))

(1)显示更多更详细的有关TCP和连接状态的信息,(2)比netstat更快速更高效。

LISTEN 0 128 *:60455 *:* users:(("rpc.statd",1644,9))

    -m:内存用量

LISTEN 0 100 127.0.0.1:smtp *:* users:(("master",1955,12))

LISTEN 0 128 :::sunrpc :::*

(5)ss -o 显示所有已建立的连接

[root@CentOS68 ~]#

netstat 通过遍历proc来或许socket信息,ss使用netlink与内核tcp_diag模块通信获取socket信息

LISTEN 0 128 :::sunrpc :::* users:(("rpcbind",1601,11))

    -p:相关的程序和PID

    -l:listen状态的连接

    -u:udp协议相关

UNCONN 0 0 *:928 *:*

LISTEN 0 128 :::39546 :::*

LISTEN 0 128 *:sunrpc *:*

UNCONN 0 0 *:sunrpc *:*

UNCONN 0 0 :::sunrpc :::*

LISTEN 0 128 ::1:ipp :::*

UNCONN 0 0 *:39797 *:*

    -e:扩展的信息

[root@CentOS68 ~]# ss -u -a

LISTEN 0 100 127.0.0.1:smtp *:*

    -o:计时器信息

LISTEN 0 100 ::1:smtp :::* users:(("master",1955,13))

[root@CentOS68 ~]# ss -pl

LISTEN 0 128 :::ssh :::*

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128 :::ssh :::*

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128 ::1:ipp :::* users:(("cupsd",1679,6))

UNCONN 0 0 *:ipp *:*

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128 :::http :::*

ESTAB 0 64 192.168.29.68:ssh 192.168.29.1:50541 timer:(on,442ms,0)

(4)-u -a 显示所有的udp socket

State Recv-Q Send-Q Local Address:Port Peer Address:Port

(2)ss –pl 显示每个进程具体打开的socket

LISTEN 0 128 *:ssh *:*

优势:

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128 *:60455 *:*

LISTEN 0 128 *:60455 *:*

LISTEN 0 128 *:sunrpc *:* users:(("rpcbind",1601,8))

    -t:tcp 协议相关

LISTEN 0 128 *:ssh *:* users:(("sshd",1841,3))

(3)-t -a 显示所有tcp socket

UNCONN 0 0 :::59503 :::*

LISTEN 0 128 127.0.0.1:ipp *:*

大话命令之—ss

LISTEN 0 128 :::http :::*

LISTEN 0 100 ::1:smtp :::*

LISTEN 0 128 :::39546 :::* users:(("rpc.statd",1644,11))

2 选项

[root@CentOS68 ~]# ss -o

LISTEN 0 128 ::1:ipp :::*

LISTEN 0 128 127.0.0.1:ipp *:*

ss是Socket Statistics的缩写。顾名思义,ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容。

    格式:ss    [option]…    [filter]

3 实例

LISTEN 0 128 :::sunrpc :::*

LISTEN 0 128 :::39546 :::*

(1)ss -l 显示本地打开的所有端口

本文由金沙官网线上发布于操作系统,转载请注明出处:大话命令之--ss

您可能还会对下面的文章感兴趣: