Use the ss to display more socket connection information in Linux

0
100

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

When the number of socket connections on the server becomes very large, either using the netstat command or directly cat /proc/net/tcp, the execution speed will be slow.

The secret of ss is that it uses tcp_diag in the TCP stack. Tcp_diag is a module for analyzing statistics, which can get the first-hand information in the Linux kernel, which ensures the fast and efficient ss.

Intsall ss

In case, you are unable to use ss command, use below command to install it.

 yum install iproute iproute-doc 

Now it is installed and ready to use.
Below are some useful commands to monitor network connections.

List all socket connections

The basic ss command, with no options, lists only all connections, no matter what state they are in.

ss

List only TCP Ports connections

To see all TCP socket connections, use the -lt option

ss -lt 

List only UDP Ports connections

To see all UDP socket connections, use the -ua option

ss -ua

Display socket PID (process ID)

To display the process ID associated with the socket connection, use the -p option

ss -p

Display summary statistics

To list summary statistics, use the -s option

ss -s

Filter connections by port number

The ss command also allows you to filter socket port Numbers or address Numbers

ss -at '( dport = :12598 or sport = :12598 )' 

Check the ss commands in the man page

For an in-depth understanding of the use of the ss command, use it to examine the man pages

man ss

These are some of the common options used with the ss command. This command is considered more advanced than the netstat command and provides detailed information about the network connection.

In conclusion:The ss command is a tool for displaying network socket-related information on a Linux system. The tool displays more details about the netstat command used to display active socket connections.

administration android Apache bionic Buster CentOS Centos 8 data database Databases debian development Docker fedora firefox How to howto install java Linux linux mint mariadb monitoring mysql network News New version Nginx opensuse PHP postgresql Programming RHEL Security server SQL tools Tutorial ubuntu unix web web server Windows Windows 10 Windows server 2019

LEAVE A REPLY

Please enter your comment!
Please enter your name here