Skip to main content

ss Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for listing sockets, listening ports, connection states, and process owners with the ss command

The `ss` command displays socket statistics on Linux and is the modern replacement for `netstat`. This cheatsheet covers the most useful `ss` flags, state and address filters, and common troubleshooting patterns.

Basic Syntax

Core ss command forms and output controls.

CommandDescription
ssShow non-listening sockets with an established connection
ss -aShow all sockets, listening and non-listening
ss -nShow numeric addresses and ports, no name resolution
ss -pShow the process that owns each socket
ss -sShow a summary of socket counts by type and state

Filter by Protocol

Restrict output to a single socket family.

CommandDescription
ss -tTCP sockets
ss -uUDP sockets
ss -xUnix domain sockets
ss -taAll TCP sockets, including listening
ss -4IPv4 sockets only
ss -6IPv6 sockets only

Listening Ports

Find services that are accepting connections.

CommandDescription
ss -lShow listening sockets only
ss -tlListening TCP sockets
ss -ulListening UDP sockets
ss -tulpnListening TCP/UDP with process and numeric output
sudo ss -tlpn 'sport = :80'Find the process listening on TCP port 80

Connection State Filters

Narrow output to a specific TCP state.

CommandDescription
ss -tn state ESTABLISHEDEstablished TCP connections
ss -tn state listeningListening TCP sockets
ss -tn state TIME-WAITConnections in TIME-WAIT
ss -tn state CLOSE-WAITConnections in CLOSE-WAIT
ss -tn state ESTABLISHED | tail -n +2 | wc -lCount established TCP connections

Address and Port Filters

Match sockets by source or destination.

CommandDescription
ss -tnp 'dport = :443'Filter by destination port
ss -tnp 'sport = :22'Filter by source port
ss -tn dst 192.168.1.5Filter by remote address
ss -tn src 192.168.1.10Filter by local address
sudo ss -tlpn sport = :8080Find the process listening on port 8080

Process and Statistics

Tie sockets to processes and read summary counts.

CommandDescription
sudo ss -tpTCP sockets with process name and PID
sudo ss -tulpnListening sockets with owning processes
ss -sTotal sockets by transport and state
ss -tnTCP sockets with numeric addresses
ss -tn dst 203.0.113.10All connections to a remote host

netstat to ss Translation

Map old netstat commands to their ss equivalents.

netstat Commandss Command
netstat -tulnss -tuln
sudo netstat -tulnpsudo ss -tulpn
netstat -atss -ta
netstat -ant | grep ESTABLISHEDss -tn state ESTABLISHED
netstat -sss -s

Troubleshooting

Common ss issues and quick fixes.

IssueCheck
-p shows no processRun with sudo to see sockets owned by other users
Filters return nothingQuote the expression and verify sport versus dport
Service names hide portsAdd -n to keep numeric ports
Output too broadStart with -t, -u, or a state filter, then narrow
Port match too broadUse a built-in filter, such as ss -tlpn 'sport = :80'

Use these guides for full walkthroughs and related tools.

GuideDescription
ss Command in LinuxFull ss guide with examples
netstat Command in LinuxThe legacy tool ss replaces
ip Command in LinuxModern routes and interface management
How to Check Listening Ports in LinuxCompare ss, netstat, and lsof
lsof Command in LinuxTie sockets and files back to processes