brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ss -s counts your sockets before you list them

Linux
~/tips/tip-networking-ss-s-summary

ss -s

Prints totals of open sockets per protocol and TCP state in a few lines.

When a server feels busy on the network, a full list of connections is a poor first look. I would rather see the totals first, and ss -s gives them in a few lines.

ss -s

It prints the total number of sockets, then a line per protocol with counts such as established, closed and time-wait connections for TCP. A pile of time-wait entries, or a very large number of established ones, shows you where to look before you run ss -tan and scroll through everything.

The man page notes that -s does not parse the socket lists. It reads its numbers from various kernel sources, so it stays cheap even with a huge number of connections, where a full listing can take a moment.

Once the summary shows something odd, narrow it down with the state filter:

ss -tan state time-wait | wc -l

That counts the time-wait sockets, minus one for the header line. Caveat: the summary only counts and does not say which program owns the sockets. Follow up with ss -tulpn (as root) to see the processes behind them.

Further reading: ss(8) manual

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link