Quickly locate listening sockets and the processes that own them to troubleshoot services and ports. 16.11.2025 | reading time: 3 min Services bind to ports; a stray listener can block a deployment. This short guide shows how to find TCP and UDP listening sockets, map them to processes, and act on the results with concrete commands you can run now. Start a quick listening socket and inspect it Create a test listener and then identify it; try this in a shell: ```bash $ python3 -m http.server 8000 & [1] 12345 $ ss -ltnp | grep 8000 LISTEN 0 128 0.0.0.0:8000 0.0.0.0:* users:("python3",pid=12345,fd=3) $ lsof -iTCP:8000 -sTCP:LISTEN -P -n python3 12345 user 3u IPv4 0x... TCP *:8000 (LISTEN) ``` The `ss` line shows protocol, state, local address and the owning process; `lsof` confirms file descriptor and PID so the admin can kill or inspect the process. Flags and variants you will use often Prefer `ss -ltnp` for TCP numeric output with process info and `ss -lupn` for UDP; use `ss -lx` for Unix domain sockets. Root privileges may be required to see process names for sockets owned by other users, and `-n` avoids costly name lookups so the output appears instantly. When simple checks are not enough If a listener is hidden or short-lived, capture the moment with `tcpdump` or probe from another host with `nmap -sT` to verify reachability; `fuser -n tcp 8000` can show PIDs holding a port and allow scripted cleanup, but always verify the process purpose before killing it. Tools that complement socket discovery Besides `ss` and `lsof`, older scripts still use `netstat -tulpen` on some systems; for deeper troubleshooting combine socket inspection with process tracing (`strace`) and packet capture to see why a service accepts or rejects connections. Wrap-up and next steps You can now list listeners, map them to PIDs and act; when the admin locates an unexpected listener he should check service configs and logs before terminating processes. Keep practicing these commands and consider studying for CompTIA Linux+ or LPIC-1, with intensive exam prep available at bitsandbytes.academy to turn these skills into a certificate. Join Bits & Bytes Academy First class LINUX exam preparation. network troubleshooting utilities processes security