ss advanced (advanced)

Advanced socket statistics: filter by state, process, and address.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

ss (socket statistics) is the modern replacement for netstat. Beyond basic port listing, it supports powerful filters by TCP state, destination, source, and process. The state filter lets you count and analyze connections in specific TCP states — critical for diagnosing connection exhaustion.

Common flags
FlagMeaning
-t --tcpTCP sockets only
-u --udpUDP sockets only
-l --listeningListening sockets only
-p --processesShow process using the socket
-n --numericDon't resolve hostnames
-s --summarySummary statistics
Examples
ss -sSocket summary: total TCP, UDP, ESTABLISHED counts · explain & risk-check →
ss -tnp state establishedAll established TCP connections with process names · explain & risk-check →
ss -tnp state time-wait | wc -lCount TIME_WAIT connections (connection exhaustion indicator) · explain & risk-check →
ss -tnp dst :443All connections to HTTPS port · explain & risk-check →
ss -lnp | grep :8080Check what's listening on port 8080 · explain & risk-check →
ss -tnp state established '( dport = :5432 )'Active connections to PostgreSQL · explain & risk-check →
Pro tip

Use `ss -s` for an instant health snapshot — if TIME_WAIT count is very high (thousands), your app isn't reusing connections. Enable TCP keep-alive or connection pooling.

Related
netstat lsof ip
Open the full explainer →More in Networking

Reference text is hand-written and may be incomplete — check man ss for your version. Test destructive commands on a non-production system first.