Legacy Linux (net-tools)

netstat vs ss

Use ss instead of netstat. The flags are deliberately similar — netstat -tulpn becomes ss -tulpn — but ss reads socket state from the kernel's netlink interface rather than by parsing /proc, which makes it far faster on a host with many connections.
Try it in a live lab

Free interactive lab. No signup. Runs in your browser.

Command by command

Legacy Linux (net-tools)LinuxWhat it gives you
netstat -tulpnss -tulpnListening TCP and UDP sockets with process names
netstat -anss -anAll sockets, numeric
netstat -tnss -tnEstablished TCP connections
netstat -rip route showRouting table moved to iproute2
netstat -iip -s link showPer-interface counters

What the output looks like

$ ss -tulpn
Netid State  Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp   LISTEN 0      5            0.0.0.0:80        0.0.0.0:*     users:(("socat",pid=2817,fd=5))

Why the two differ

netstat works by opening and parsing files under /proc/net/. On a host with tens of thousands of sockets that means reading and text-parsing a very large amount of data on every invocation, which is why it can take seconds to return. ss asks the kernel directly over a netlink socket and can ask it to filter server-side, so it returns almost immediately and can express filters netstat has no syntax for, such as ss state established '( dport = :443 )'.

The trap

netstat -r has no ss equivalent, and people looking for one waste time. Routing moved to a different tool entirely: use ip route show. ss deals only with sockets.

Common questions

Do I need root for ss -p?

To see process names for sockets you do not own, yes. Without privileges ss -p silently omits the process column for other users' sockets rather than erroring, which makes it look as though nothing is listening.

What replaced netstat -s for protocol statistics?

ss -s gives a short socket summary, but for the full per-protocol counters netstat printed, use nstat or read /proc/net/snmp directly.

Stop reading, start running

Open the lab, go live, and run ss -tulpn against real Linux networking in your browser. No install, no signup.

Launch the lab →