Inspect protocol usage with ss -s
In this step, we will use the ss
command, which is a utility to investigate sockets. It is often considered a replacement for netstat
as it can display more TCP and state information.
Similar to netstat
, the ss
command also has a -s
option to display summary statistics for various socket types. This can give you a quick overview of the number of open connections and sockets for different protocols.
Open your terminal if it's not already open.
Type the following command and press Enter:
ss -s
You will see output that summarizes the number of sockets in different states and for different protocols. The output might look like this:
Total: 1234 (kernel 5678)
TCP: 90 (estab 50, closed 20, orphaned 5, synrecv 3, timewait 10, ...)
UDP: 15
RAW: 0
UNK: 0
TCP:
ESTAB 50
TIME-WAIT 10
... (other TCP states)
Let's break down the output:
Total
: Shows the total number of sockets.
TCP
: Provides a summary of TCP sockets, including the total number and counts for different states like estab
(established), closed
, timewait
, etc.
UDP
: Shows the total number of UDP sockets.
RAW
: Shows the total number of raw sockets.
UNK
: Shows the number of unknown socket types.
Below the summary lines, ss -s
often provides a more detailed breakdown of TCP states.
Comparing the output of netstat -s
and ss -s
, you might notice that ss -s
focuses more on socket states, which can be very helpful for diagnosing connection issues. For example, a large number of sockets in the TIME-WAIT
state might indicate a problem with closing connections efficiently.
Using ss -s
provides another perspective on network activity compared to netstat -s
. Both commands are valuable tools for network monitoring and troubleshooting in Linux.
You have now learned how to use netstat -s
, explore /proc/net
, and use ss -s
to inspect network protocol statistics. These are fundamental skills for understanding network activity on a Linux system.
Click Continue to complete this lab.