netstat is a classic command for checking network connections, listening ports and routing information on Linux systems. On modern systems, ss is often preferred, but netstat is still useful on older servers and troubleshooting notes.
Show listening TCP and UDP ports
netstat -tuln
This lists listening TCP and UDP sockets with numeric addresses and ports.
Show programs using ports
sudo netstat -tulpn
The -p option shows the process using each socket. This is useful when you need to know which service is listening on a port.
Show routing table
netstat -rn
This shows the kernel routing table with numeric addresses.
For newer systems, the equivalent modern commands are usually ss -tuln and ip route.