[Scenario 1: View network connection statistics of the current server] $ ss-sTotal: 295 (kernel312) TCP: 48 (estab1, closed31, orphaned0, synrecv0, & nbs
[Scenario 1: view the network connection statistics of the current server]
$ ss -sTotal: 295 (kernel 312)TCP: 48 (estab 1, closed 31, orphaned 0, synrecv 0, timewait 0/0), ports 13Transport Total IP IPv6* 312 - -RAW 0 0 0UDP 2 2 0TCP 17 12 5INET 19 14 5FRAG 0 0 0
When the server generates a large number of sockets connections, we will use this command for macro statistics.
Scenario 2: View all open network ports]
$ ss -lRecv-Q Send-Q Local Address:Port Peer Address:Port0 128 :::webcache :::*0 128 :::http :::*0 128 :::snapenetio :::*0 128 *:snapenetio *:*0 50 *:8531 *:*0 9 :::ftp :::*0 9 *:ftp *:*0 128 *:ddi-tcp-1 *:*0 100 ::1:smtp :::*0 100 127.0.0.1:smtp *:*0 128 *:8541 *:*0 128 127.0.0.1:entextxid *:*0 50 *:12421 *:*0 10 *:amqp *:*0 128 *:12521 *:*0 50 *:mysql *:*
If the-pl parameter is used, the specific program name is listed. You will see something similar to this in the output:
("nginx",15786,6)
We can know that a socket connection belongs to the nginx program, and the PID of the nginx program is 15786.
[Scenario 3: View All socket connections on this server]
You can simply use the-a option to list all network connections.
#ss -a
If you only want to view TCP sockets, use the-ta option;
If you only want to view UDP sockets, use the-ua option;
If you only want to view RAW sockets, use the-wa option;
If you only want to view UNIX sockets, use the-xa option.