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 how netstat behaves.

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 -tuln for listening sockets on modern Linux.
  • Prefer ip route for routes.
  • Some minimal systems do not install netstat by default.
  • Use sudo when process names are hidden.