Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use the ss command in linux

Shulou Source: shulou.com Published: 2022-06-02 09:55:45 10月28日 Update

This article introduces how to use ss command in linux, the content is very detailed, interested friends can refer to it, I hope it can help you.

SS is an abbreviation for Socket Statistics. The ss command can be used to get socket statistics, and it displays something similar to netstat. The advantage of ss is that it can display more detailed information about TCP and connection status, and it is faster than netstat. When the number of socket connections to the server becomes very large, execution will be slow whether using netstat command or cat /proc/net/tcp directly. The ss command takes advantage of tcp_diag in the TCP stack. tcp_diag is a module for analyzing statistics and getting first-hand information about the Linux kernel, so ss command performance is much better.

common options

-h, --help help

-V, --version Display version number

-t, --tcp Shows TCP sockets

-u, --udp Displays UDP sockets

-x, --unix Displays unix domain sockets, same as-f option

-n, --numeric Does not resolve the name of the service, e.g. port "22" does not appear as "ssh"

-l, --listening Show only listening ports

-p, --processes Show processes listening on ports (sudo required on Ubuntu)

-a, --all For TCP, both listening ports and established connections are included.

-r, --resolve Interprets IP as domain name and port number as protocol name

common use cases

If you do not add the option ss command default output all established connections (excluding listening ports), including tcp, udp, and unix socket three types of connections:

View ports on which hosts listen

$ ss -tnl

Resolve IP and port numbers with the-r option

$ ss -tlr

Use the-p option to view the name of the program listening on the port

$ sudo ss -tlp

The last column is the name of the program running. You can also continue filtering through grep:

$ sudo ss -tlp | grep ssh

View TCP connections made

-a --all For TCP, both listening ports and established connections are included.

$ ss -tna

display more information

-o, --options Display time information

-m, --memory Displays memory used by socket

-i, --info Show more information inside TCP

Display summary information

$ ss -s

How to use the ss command in linux is shared here. I hope the above content can be of some help to everyone and learn more. If you think the article is good, you can share it so that more people can see it.

Tags: Port command information monitoring more name content help slogan status program service statistics interpretation yes same host advantage interest memory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MySQL Xiaomi Microsoft NVidia