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 state established filters linux connections by state and port

Linux
~/tips/tip-linux-ss-state-filter-port

ss -tn state established '( dport = :443 )'

Lists only the TCP connections in a chosen state that match a port, instead of every socket.

I use the state filter in ss when I only care about live connections to one service, not every socket on the box.

ss -tn state established '( dport = :443 )'
ss -tn state established '( sport = :22 )'

state established hides listeners and half-open sockets. The expression in brackets matches the destination or source port, so the first line shows outgoing HTTPS connections and the second shows who is connected to your SSH server. Quote the brackets, or the shell tries to read them. Add -p as root to see the owning process. The filter language also knows states like time-wait and syn-recv, which helps when you suspect a connection pile-up.

Further reading: ss manual page

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