ss命令用于显示socket状态。
ss可以显示PACKET sockets, TCP sockets, UDP sockets, DCCP
sockets, RAW sockets, Unix domain sockets等等统计。
它比其他工具展示等多tcp和state信息。
它是一个非常实用、快速、有效的跟踪IP连接和sockets的新工具。
SS命令可以提供如下信息:
1.所有的TCP sockets
2.所有的UDP sockets
3.所有ssh/ftp/ttp/https持久连接
4.所有连接到Xserver的本地进程
5.使用state(例如:connected, synchronized, SYN-RECV,
SYN-SENT,TIME-WAIT)、地址、端口过滤
6.所有的state FIN-WAIT-1 tcpsocket连接以及更多
ss -l 显示本地打开的所有端口
ss -pl 显示每个进程具体打开的socket
ss -t -a 显示所有tcp socket
ss -u -a 显示所有的UDP Socekt
ss -o state established '( dport = :smtp or sport = :smtp
)' 显示所有已建立的SMTP连接
ss -o state established '( dport = :http or sport = :http
)' 显示所有已建立的HTTP连接
ss -x src /tmp/.X11-unix/* 找出所有连接X服务器的进程
ss -s 列出当前socket详细信息
显示sockets简要信息
列出当前已经连接,关闭,等待的tcp连接
[root@localhost /]# ss -s
Total: 449 (kernel 455)
TCP: 14 (estab 1, closed 2, orphaned 0,
synrecv 0, timewait 0/0), ports 9
Transport Total
IP
IPv6
*
455
-
-
RAW
0
0
0
UDP
10
7
3
TCP
12
7
5
INET 22
14
8
FRAG 0
0
0
列出当前监听端口
[root@localhost /]# ss -l
State
Recv-Q Send-Q
Local Address:Port
Peer Address:Port
LISTEN 0
128
*:42062
*:*
LISTEN 0
128
:::sunrpc
:::*
LISTEN 0
128
*:sunrpc
*:*
LISTEN 0
128
*:http
*:*
LISTEN 0
128
:::ssh
:::*
LISTEN 0
128
*:ssh
*:*
LISTEN 0
128
127.0.0.1:ipp
*:*
LISTEN 0
128
::1:ipp
:::*
LISTEN 0
100
::1:smtp
:::*
LISTEN 0
100
127.0.0.1:smtp
*:*
LISTEN 0
128
:::58074
:::*
ss列出每个进程名及其监听的端口
[root@localhost /]# ss -pl
State
Recv-Q Send-Q
Local Address:Port
Peer Address:Port
LISTEN
0
128
*:42062
*:*
users:(("rpc.statd",1313,9))
LISTEN
0
128
:::sunrpc
:::*
users:(("rpcbind",1268,11))
LISTEN
0
128
*:sunrpc
*:*
users:(("rpcbind",1268,8))
LISTEN
0
128
*:http
*:*
users:(("nginx",1765,6),("nginx",1766,6))
LISTEN
0
128
:::ssh
:::*
users:(("sshd",1487,4))
LISTEN
0
128
*:ssh
*:*
users:(("sshd",1487,3))
LISTEN
0
128
127.0.0.1:ipp
*:*
users:(("cupsd",1369,7))
LISTEN
0
128
::1:ipp
:::*
users:(("cupsd",1369,6))
LISTEN
0
100
::1:smtp
:::*
users:(("master",1563,13))
LISTEN
0
100
127.0.0.1:smtp
*:*
users:(("master",1563,12))
LISTEN
0
128
:::58074
:::*
users:(("rpc.statd",1313,11))