Skip to content

/compare/ss/ss-vs-netstat

ss vs netstat: differences and equivalent commands

The commands on this page have not been executed by our verification runner yet.updated
tool
ss / netstat
compares
ss vs netstat

ss (from iproute2) is the current Linux tool for listing sockets; netstat (from net-tools) is its deprecated predecessor. They show the same kind of information, and most options carry over: netstat -tulpn becomes ss -tulpn. ss reads socket data from the kernel through netlink, so it is faster on machines with many connections, and it has a filter language for states, ports and addresses. Many minimal distributions and container images no longer install netstat at all (netstat: command not found); use ss, or install net-tools if a script requires it.

Side by side

ssnetstat
Packageiproute2 (installed by default on most distributions)net-tools (deprecated, often not installed)
Data sourceNetlink (sock_diag), /proc as fallbackParses /proc/net/* text files
Speed with many socketsFastSlow with tens of thousands of sockets
FiltersBuilt in: state, sport, dport, src, dst, with and/orOnly through grep
Extra detailTCP internals with -i (rtt, cwnd, retrans), timers with -o, memory with -mTimers with -o
Other jobsSockets onlyAlso routes (-r), interfaces (-i), multicast (-g): use ip route, ip -s link, ip maddr instead

Equivalent commands

Tasknetstatss / iproute2
Listening TCP and UDP ports with processnetstat -tulpnss -tulpn
All TCP connections, numericnetstat -tanss -tan
Established connections onlynetstat -tn | grep ESTABLISHEDss -tn state established
Connections to port 443netstat -tn | grep ":443 "ss -tn '( dport = :443 or sport = :443 )'
Summary statisticsnetstat -sss -s (socket totals); nstat for protocol counters
Unix domain socketsnetstat -xss -x
Routing tablenetstat -rnip route
Interface countersnetstat -iip -s link

Output differences to know

  • State names are abbreviated in ss (ESTAB, TIME-WAIT, CLOSE-WAIT) and written in full in netstat (ESTABLISHED, TIME_WAIT). Scripts that grep for ESTABLISHED need changing.
  • ss -p prints users:(("nginx",pid=1234,fd=6)); netstat -p prints 1234/nginx.
  • Without -l or -a, ss shows only non-listening sockets (connections), like netstat without -l/-a.
  • Both need root to show processes owned by other users.

On macOS and BSD, netstat is still the native tool and ss does not exist; use netstat -anv -p tcp or lsof -nP -iTCP -sTCP:LISTEN.

Sources