How do you find what's using a port or consuming resources on Linux?
⚡
Quick Answer
Use ss -tlnp (or lsof -i) for ports, and top/ps for CPU/memory by process.
Detailed Answer
ss -tlnp lists listening TCP sockets with the owning process; lsof -i :PORT does the same. For resource hogs, top/htop sort by CPU or memory, and ps aux --sort=-%mem shows the top consumers. These are the first commands in any triage.
Code Example
ss -tlnp | grep :8080
💡
Interview Tip
ss has replaced netstat — use ss -tlnp.
linuxnetworkingtroubleshooting