ss is a Linux command for inspecting sockets: it lists network and local connections together with their state, queue sizes, addresses and owning processes. Part of the iproute2 package, the ss command is the modern replacement for the older netstat and is a core tool for monitoring on Linux servers and desktops.
The name stands for socket statistics. Administrators use ss to answer practical questions quickly: which service listens on a port, how many connections are stuck in a given state, whether data is piling up in a queue, and which process owns a suspicious connection.
How the ss command reads socket data
The ss command obtains its information from the kernel through the netlink sock_diag interface, also known as inet_diag for TCP and UDP sockets. Instead of parsing large text files under /proc/net, as netstat traditionally does, ss asks the kernel for filtered binary records, which makes it considerably faster on busy hosts with tens of thousands of connections.
Filtering can happen inside the kernel when a state or port filter is given, so only matching sockets cross into user space. This matters on load balancers and proxies, where an unfiltered listing may contain more than 100,000 entries and take noticeable time to print.
The table below contrasts the two data paths and their practical consequences.
| Aspect | The ss command | The netstat command |
|---|---|---|
| Data source | Netlink sock_diag | Text files under /proc/net |
| Filtering | In the kernel for many filters | In user space after reading |
| Speed on large hosts | Fast, scales well | Slow with many sockets |
| TCP internals | RTT, cwnd, retransmits with -i | Not available |
| Package | iproute2, maintained | net-tools, deprecated |
Essential options and output columns
Most ss invocations combine a few single-letter options that select the socket family, the state and the level of detail. The widely used form ss -tulpn shows TCP and UDP listening sockets with numeric addresses and the processes that own them, which is the standard way to check open ports.
The following table lists the options that cover the majority of daily monitoring tasks.
| Option | Meaning | Typical purpose |
|---|---|---|
| -t / -u | TCP or UDP sockets | Limit output to one protocol |
| -l / -a | Listening or all sockets | Find services or see every connection |
| -n | Numeric output | Skip slow name and service resolution |
| -p | Show owning process | Identify the program behind a port |
| -s | Summary statistics | Count sockets per state and protocol |
| -i | Internal TCP information | Inspect RTT, congestion window, retransmits |
| -m | Socket memory usage | Diagnose buffer pressure |
| -x | Unix domain sockets | Inspect local inter-process communication |
The default output contains the columns Netid, State, Recv-Q, Send-Q, local address and peer address, plus a process column when -p is used. The meaning of Recv-Q and Send-Q depends on the state: for a listening socket, Recv-Q is the current accept queue length and Send-Q is the configured backlog limit; for an established socket, Recv-Q counts bytes not yet read by the application and Send-Q counts bytes not yet acknowledged by the peer.
Filtering connections by state and address
A distinctive strength of ss is its filter expression language. A state filter such as ss -t state established restricts output to one TCP state, and address filters such as dport = :443 or src 10.0.0.0/8 select connections by port or network. Expressions can be combined with and, or and parentheses, which replaces long grep pipelines with a single precise query.
Knowing what each TCP state indicates turns a raw listing into a diagnosis. The table below lists the states that most often appear in monitoring work.
| State | What it means | Signal when counts are high |
|---|---|---|
| LISTEN | Waiting for incoming connections | Normal; check for unexpected services |
| ESTAB | Connection carrying data | Load level or connection leaks |
| SYN-RECV | Handshake started by a client | Possible SYN flood or slow accept |
| TIME-WAIT | Closed locally, waiting out old packets | Many short-lived outgoing connections |
| CLOSE-WAIT | Peer closed, application has not | Application fails to close sockets |
| FIN-WAIT-2 | Waiting for the peer to close | Peer keeps half-open connections |
ss among Linux monitoring tools
The ss command focuses on sockets and connections, so it complements rather than replaces other monitoring tools. lsof shows every open file, including sockets, per process; strace reveals the system calls a process makes on a socket; and sar records network counters over time. A typical investigation starts with ss -s for an overview and narrows down with filters.
The decision table below matches common questions with the most suitable tool.
| Question | Recommended tool | Reason |
|---|---|---|
| Which process listens on port 8080 | ss -ltnp | Direct port to process mapping |
| How many connections per state | ss -s or state filter | Fast kernel-side counting |
| Which files and sockets a process holds | lsof -p PID | Covers all descriptor types |
| Why a connection is slow | ss -ti | Shows RTT and retransmissions |
| How traffic changed over a day | sar -n DEV | Historical interface statistics |
Common mistakes when reading ss output
Several misreadings recur even among experienced administrators, and most of them stem from missing privileges or misunderstood columns.
- Running -p without root: the process column stays empty for sockets owned by other users, which looks like orphaned connections.
- Treating TIME-WAIT as a fault: thousands of TIME-WAIT sockets are normal on clients making many short connections.
- Ignoring CLOSE-WAIT growth: a steadily rising count usually indicates an application bug that never closes sockets.
- Misreading Send-Q on listeners: it shows the backlog limit, not queued data.
- Forgetting -n: name resolution can make ss slow and hide the real port numbers.
Understanding it simply
Every network conversation on a computer runs through a socket, a kind of numbered doorway. The ss command is like a building directory that lists every open doorway, who stands behind it and whether a conversation is starting, active or ending.
Administrators use it to see which programs accept visitors, how many visitors are inside and whether anyone is stuck waiting. It is quick, precise and already installed on almost every modern Linux system.
Applied in practice
An operations engineer receives an alert that a Java API server on Linux has started refusing requests, although CPU and memory look normal. The engineer runs ss -s and sees about 9,000 TCP sockets, far above the usual 1,500. A follow-up query, ss -tn state close-wait, shows that more than 7,000 of them are in CLOSE-WAIT, all pointing to the same database proxy on port 6432.
Running ss -tnp state close-wait as root confirms that the API process owns these sockets. The finding points to connections the application never closes after the proxy ends them. The team traces the issue to a missing close call in an error path of the connection pool, deploys a fix, and the CLOSE-WAIT count drops below 50 within an hour. The root cause was identified in minutes without restarting the service.