The Linux ss
Command #
The Linux ss
(Socket Statistics) command is a modern alternative to the netstat
command, providing faster and more detailed information about network connections, sockets, and protocol statistics. It is widely used for network troubleshooting and performance analysis.
Key Usage and Syntax of the ss
Command #
The basic syntax of the ss
command is:
ss [OPTIONS] [FILTER]
- OPTIONS: Flags to control the type of information displayed.
- FILTER: Conditions to filter the output.
ss
Command Cheatsheet Table #
Command | Description |
---|---|
ss |
Displays all established network connections. |
ss -t |
Shows only TCP connections. |
ss -u |
Shows only UDP connections. |
ss -l |
Displays listening ports and sockets. |
ss -r |
Displays resolved hostnames for addresses. |
ss -s |
Shows a summary of protocol statistics. |
ss -p |
Displays the PID and program name for connections. |
ss -n |
Shows raw IP addresses without resolving hostnames. |
Common Use Cases #
View Active Network Connections #
ss
Displays all current network connections with detailed information.
Show Only Listening Sockets #
ss -l
Lists sockets currently in the listening state.
Monitor Specific Protocols #
To filter connections by protocol, use:
ss -t
for TCPss -u
for UDP
Analyze Process Connections #
ss -p
Identifies the processes associated with network sockets.
Inspect Network Performance #
ss -s
Provides protocol-level statistics, including retransmissions and errors.
Advanced Usage #
Filter Connections by Address #
ss dst 192.168.1.1
Filters connections where the destination address is 192.168.1.1
.
Monitor Listening Ports by Port Number #
ss -l | grep ":80"
Displays processes listening on port 80.
View Sockets in Specific States #
ss state established
Displays all connections in the “established” state.
Using ss
with RELIANOID Solutions #
RELIANOID leverages the ss
command to optimize network configurations and diagnose connectivity issues in enterprise environments. Its efficiency and rich data output make it ideal for monitoring high-performance infrastructures.
Debug Proxy Services #
Check if proxy servers are listening on the expected ports:
ss -l | grep ":443"
Analyze Load Balancer Traffic #
Track active TCP connections to backend services:
ss -t | grep "10.0.0.5"
Investigate Delayed Connections #
ss state time-wait
Displays connections in the “time-wait” state, which may indicate bottlenecks.
Monitor Dropped Packets #
Identify network reliability issues:
ss -s | grep -i "drop"
Security Considerations #
Always secure access to network diagnostic tools like ss
to prevent unauthorized monitoring or exposure of sensitive information.
Summary #
The ss
command is a versatile and efficient tool for network analysis and troubleshooting. Its superior speed and detailed output make it a preferred choice over netstat
. At RELIANOID, ss
is integral to maintaining secure and performant network solutions.