netstat and ss
What's listening on port 80? What connections are open? These commands tell you.
ss - The Modern Tool
ss (socket statistics) is the modern replacement for netstat.
Show All Connections
Listening Ports Only
TCP Connections
UDP Connections
The Useful Combo: ss -tulpn
This is the command you'll use most:
t- TCPu- UDPl- Listeningp- Show process namen- Numeric (don't resolve names)
Remember: tulpn
ss -tulpn - "What's listening and what process owns it?"
You'll type this a hundred times.
Find What's on a Port
Or use sport (source port) filter:
netstat - The Classic
netstat is older but still widely used:
Same flags, similar output.
ss vs netstat
ss is faster and has more features. netstat might not be installed on newer systems. Learn ss, fall back to netstat on older systems.
Active Connections
Shows active (established) connections.
Count Connections by State
Good for quick health check.
Troubleshooting Scenarios
Port Already in Use
Check If Service Is Listening
Too Many Connections?
Which command shows what process is listening on port 80?
Quick Reference
| Command | Shows |
|---|---|
ss -tulpn | Listening ports + processes |
ss -t | TCP connections |
ss -tn state established | Active connections |
ss -s | Connection statistics |
netstat -tulpn | Same as ss (legacy) |
Key Takeaways
ss -tulpnis your go-to (listening ports + processes)- Use
grep :PORTto find specific ports ssis modern,netstatis legacy-nkeeps output numeric (faster)-pshows which process owns the socket
Next: remote connections with SSH.