Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the ss command in Linux

Shulou Source: shulou.com Published: 2022-06-01 14:39:28 09月22日 Update

Most people do not understand the knowledge of this article "how to use ss commands in Linux", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use ss commands in Linux" article.

Ss is the abbreviation of Socket Statistics. The ss command can be used to get socket statistics, which displays something similar to netstat. But the advantage of ss is that it can display more and more detailed information about TCP and connection status, and it is faster than netstat.

Show all sockets with established connections

The ss command takes no options and displays a list of all sockets with established connections.

[root@localhost ~] # ss

Suppress the title line in the output

If you want to cancel the title line in the command output, you can use the-H option.

[root@localhost] # ss-H

Show only tcp connections

If you only want to display the tcp connection in the output of the command, you can use the-t option:

[root@localhost ~] # ss-t shows only udp connections

If you only want to display udp connections in the output of the command, you can use the-u option:

[root@localhost ~] # ss-u shows only unix connections

If you only want to display unix socket connections in the output of the command, you can use the-x option:

[root@localhost ~] # ss-x shows only the socket that is listening

If you want to display only the sockets being listened on, you can use the-l option.

[root@localhost ~] # ss-l displays summary information

Use the-s option to display summary information:

[root@localhost] # ss-sTotal: 156TCP: 3 (estab 1, closed 0, orphaned 0, timewait 0) Transport Total IP IPv6RAW 1 0 1 UDP 3 21 TCP 3 21 INET 7 4 3 FRAG 0 0 displays only IPv4/IPv6 sockets

If you only want to show ipv4 listeners, you can use the-4 and-l options.

[root@localhost] # ss-4l

If you only want to show ipv6 listeners, you can use the-6 and-l options.

[root@localhost ~] # ss-6l does not resolve IP addresses to hostnames

If you do not want to resolve ip addresses to host names, you can use the-n option to prevent commands from resolving IP addresses to host names. But this also prevents the resolution of the port number:

[root@localhost] # ss-n-4lNetid State Recv-Q Send-Q Local Address:Port Peer Address:Port udp UNCONN 00 192.168.43.131%ens160:68 0.0. 0.0 * udp UNCONN 0 0127.0.0.1VOR 323 0.0.0.0Vue * tcp LISTEN 0 128 0 .0.0.0: 22 0.0.0.0 * above is the content of this article on "how to use ss commands in Linux" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Tags: Commands content sockets output information hosts addresses abstracts articles more titles status knowledge articles values advantages slogans names most of which are Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker Apple Xiaomi Linux