ss command
Detailed Explanation
The ss (socket statistics) command is a modern, faster replacement for the netstat command. It dumps socket statistics and allows displaying information in a similar fashion to netstat. It can display more TCP and state information than other tools, making it highly valuable for system administrators and developers.
Basic Syntax
ss [options] [FILTER]
Common Flags/Options
| Option | Description |
|---|---|
-t | Display TCP sockets. |
-u | Display UDP sockets. |
-l | Display listening sockets. |
-a | Display all sockets (listening and non-listening). |
-n | Do not resolve service names (show numeric port numbers). |
-p | Show process using the socket. |
Real-world Examples
List all listening TCP connections with numeric ports and process names:
sudo ss -tlnp
List all established TCP connections:
ss -t -a state established
List all UDP sockets:
ss -ua
Show sockets connected to a specific destination IP:
ss dst 192.168.1.1
Show sockets matching a specific source port:
ss sport = :80