Netstat/SS
Netstat vs. ss
netstat gets its information from /proc/net directly. It parses the file and prints out information based on it.
ss was written more recently to use the netlink API (it will fall back to proc/net if netlink is unavailable). The information in both systems is essentially the same (from what I've seen), but here are some arguments for why to use ss
It's faster (I just read that a lot, I don't find
netstatto be noticeably slower)Netlink exposes more TCP states (again I mostly look for
LISTENso that's not a huge selling point)It has better default argument
The default arguments is a little more compelling. netstat by default will try to resolve IP addresses through DNS which really slows it down. It also opens a bunch of new UDP sockets, which might clutter the picture if you're investigating something. netstat -n stops this behavior, but ss has that on by default (you can use ss -r if you do want the resolution).
time ss -nltp
real 0m0.129s
user 0m0.029s
sys 0m0.097s
time netstat -nltp
real 0m0.015s
user 0m0.004s
sys 0m0.010sNetstat
SS
Last updated
Was this helpful?