ss / netstat Commands

Complete ss / netstat commands reference — 55 commands across 3 categories. Quick reference cheat sheet for Linux.

ss is the modern replacement for netstat on Linux — it reads socket state directly from the kernel, so it is faster and shows more — and its options are designed to be stacked into short strings such as ss -tulpn. The table lists the options and filter syntax from the manual; the notes explain the handful of combinations that answer nearly every "what is listening" and "who is connected" question.

Options (44)

ShortcutAction
ss -hShow summary of options
ss -VOutput version information
ss -HSuppress header line
ss -QSuppress sending and receiving queue columns
ss -OPrint each socket's data on a single line
ss -nDo not try to resolve service names
ss -rTry to resolve numeric address/ports
ss -aDisplay both listening and non-listening (for TCP this means established connections) sock
ss -lDisplay only listening sockets (these are omitted by default)
ss -BDisplay only TCP bound but inactive (not listening, connecting, etc.) sockets (these are o
ss -oShow timer information
ss -eShow detailed socket information
ss -mShow socket memory usage
ss -pShow processes using sockets
ss -TShow threads using sockets
ss -iShow internal TCP information
ss --tosShow ToS and priority information
ss --cgroupShow cgroup information
ss --tipcinfoShow internal tipc socket information
ss -KAttempts to forcibly close sockets
ss -sPrint summary statistics
ss -EContinually display sockets as they are destroyed
ss -ZAs the -p option but also shows process security context
ss -zAs the -Z option but also shows the socket context
ss -N NSNAMESwitch to the specified network namespace name
ss -bShow socket classic BPF filters (only administrators are allowed to get this information)
ss -4Display only IP version 4 sockets (alias for -f inet)
ss -6Display only IP version 6 sockets (alias for -f inet6)
ss -0Display PACKET sockets (alias for -f link)
ss -tDisplay TCP sockets
ss -uDisplay UDP sockets
ss -dDisplay DCCP sockets
ss -wDisplay RAW sockets
ss -xDisplay Unix domain sockets (alias for -f unix)
ss -SDisplay SCTP sockets
ss --vsockDisplay vsock sockets (alias for -f vsock)
ss -MDisplay MPTCP sockets
ss --inet-sockoptDisplay inet socket options
ss -f FAMILYDisplay sockets of type FAMILY
ss -A QUERYList of socket tables to dump, separated by commas
ss -D FILEDo not display anything, just dump raw information about TCP sockets to FILE after applyin
ss -F FILERead filter information from FILE
ss --bpf-mapsPretty-print all the BPF socket-local data entries for each socket
ss --bpf-map-id=MAP_IDPretty-print the BPF socket-local data entries for the requested map ID

Filter Expressions (6)

ShortcutAction
{dst|src} [=] HOSTTest if the destination or source matches HOST
{dport|sport} [OP] [FAMILY:]:PORTCompare the destination or source port to PORT
dev [=|!=] DEVICEMatch based on the device the connection uses
fwmark [=|!=] MASKMatches based on the fwmark value for the connection
cgroup [=|!=] PATHMatch if the connection is part of a cgroup at the given path
autoboundMatch if the port or path of the source address was automatically allocated (rather than e

Usage Examples (5)

ShortcutAction
ss -t -aDisplay all TCP sockets
ss -t -a -ZDisplay all TCP sockets with process SELinux security contexts
ss -u -aDisplay all UDP sockets
ss -x src /tmp/.X11-unix/*Find all local processes connected to X server
ss -a -A 'all,!tcp'List sockets in all states from all socket tables but TCP
📄 View Printable Cheat Sheet — Download as PDF or print · 🧩 Combine with other tools

Related Shortcut Pages

tcpdump Nmap Nginx Docker Kubernetes (kubectl) htop

Search 18,500+ shortcuts across 268 platforms

Explore All Platforms Practice Shortcuts
📜 Every shortcut on this page is taken from the official ss / netstat documentation — man7.org
🔧 Spotted an error or a missing shortcut? Suggest an edit on GitHub — every accepted fix goes live on this page, the API and the CLI.

The combinations people actually type

Most invocations combine a socket-type letter with a state option: ss -l shows only listening sockets and ss -a shows all, while ss -t -a and ss -u -a restrict to TCP and UDP. Add ss -n to skip DNS and service-name lookups (faster and less confusing) and ss -p to show the owning process and PID, which usually needs root. The result, ss -tulpn, is the netstat replacement everyone memorises: every listening TCP and UDP port with the program behind it. ss -s prints summary counts by state, which is a quick health check on a busy server.

Filtering

Rather than piping to grep, ss accepts filter expressions after the options. {dst|src} [=] HOST matches by address — ss -t dst 10.0.0.5 — and {dport|sport} [OP] [FAMILY:]:PORT matches by port, with operators such as = and >: ss -t sport = :22. State filters go before the expression, ss -t state established or state time-wait, and answer "how many connections are stuck". ss -4 and ss -6 restrict to one IP family, and ss -x with a path pattern finds Unix-socket clients, as in the X server example in the table.

Diagnostics

ss -i prints internal TCP information per connection — congestion window, RTT, retransmits — which settles quickly whether a slow transfer is a network problem or an application one. ss -o shows timers such as keepalive and retransmission countdowns, ss -m socket memory, and ss -e extended details including the socket's inode. ss -E watches sockets as they are destroyed, and ss -K forcibly closes sockets matching a filter (kernel support required), which is occasionally the only way to clear a stuck connection without restarting the service.

Frequently asked questions

What is the ss equivalent of netstat -tulpn?

ss -tulpn: TCP and UDP listening sockets, numeric, with process names. The letters are the same.

How do I see connections to a specific port?

ss -t state established '( dport = :443 or sport = :443 )', or simply ss -t sport = :443 for the local side.

Why does ss not show process names?

The -p option needs permission to read other users' processes; run it with sudo.

How do I count connections by state?

ss -s gives totals per state. For one state, ss -t state time-wait | wc -l.

🤖 Ask AI about ss / netstat shortcuts

Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"

ChatGPT Claude Perplexity Gemini Grok