Network
netstat
Show network connections, routing tables, and listening ports.
networksocketportroutelegacy
Additional Notes
netstat shows network connections, listening ports, routing tables, and interface statistics. It is older and often replaced by ss, ip, and route equivalents on modern systems.
You will still see it in tutorials and older servers.
Syntax
netstat [options]
Parameters
options: Flags that change hownetstatbehaves.
Common Options
-t: TCP.-u: UDP.-l: Listening sockets.-n: Numeric addresses and ports.-p: Show process/program information.-a: Show all sockets.-r: Show routing table.-i: Show interface table.
Examples
netstat -tuln
Show listening TCP and UDP ports numerically.
sudo netstat -tulnp
Show listening ports with process names.
netstat -rn
Show routing table numerically.
netstat -i
Show network interface statistics.
Practical Notes
- Prefer
ss -tulnfor listening sockets on modern Linux. - Prefer
ip routefor routes. - Some minimal systems do not install
netstatby default. - Use
sudowhen process names are hidden.