🐧 Linux / Shell Scripting
Intermediate
How do netstat and ss show network connections?
Answer
ss (socket statistics) is the modern replacement for the deprecated netstat. Common usage: ss -tlnp shows all TCP (t) listening (l) sockets with numeric ports (n) and the process name/PID (p). ss -an shows all connections. ss -s prints a summary of socket counts by state. netstat -tlnp does the same on older systems. For troubleshooting connectivity: ss -tn dst 192.168.1.1 shows connections to a specific IP. Check TIME_WAIT accumulation (can cause port exhaustion) with ss -t state time-wait | wc -l. Both tools are essential for verifying that your application is listening on the expected port and diagnosing connection issues.
Previous
What are strace and ltrace used for?
Next
How do you use the ip command for network configuration?