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 -tulpn shows which program is listening on which port

Linux
~/tips/ss-listening

cat ~/tips/ss-listening.md

Shows which program is using which network port, useful when a port is already taken.

When a port is already in use, I want one command that tells me which program has it. This is the one I would learn first.

Run ss -tulpn. Each letter is a flag from the ss man page: -t shows TCP sockets, -u UDP, -l only listening sockets, -p the processes that use them and -n keeps numbers instead of resolving names. You get a list of ports with the program next to each.

Look for the port you care about, for example ss -tulpn | grep :8080. The last column names the process that holds it, so you know whether to stop it or choose another port for your container.

Caveat: the process column is often empty unless you run it with enough rights, usually with sudo. That is how it behaves on the systems I know, and the man page only says that -p shows the processes. Also remember that a service listening on 127.0.0.1 is only reachable from the machine itself, which is a good thing to notice before you expose something by accident.

Further reading: man7.org: ss(8), On this site: getent hosts shows what your programs really resolve

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