Netstat Cheat Sheet

Below is a cheat sheet for netstat commands:

Displaying Network Statistics

Display All Connections:

netstat -a

Display Listening Ports:

netstat -l

Display All Active Connections:

netstat -t

Filtering Output

Show Numerical Addresses:

netstat -n

Show Processes Using Ports:

netstat -p

Displaying IPv4 or IPv6 Connections

Show IPv4 Connections:

netstat -4

Show IPv6 Connections:

netstat -6

Displaying Additional Information

Show Detailed Statistics:

netstat -s

Show PID and Program Name for Ports:

netstat -p

Miscellaneous

Display Kernel Routing Table:

netstat -r

Display Network Interfaces:

netstat -i

Display Network Services:

netstat -nlt

Show All Listening Sockets and PIDs:

netstat -plnt

Display Information about Kernel Modules:

netstat -M

Common Options

  • -a or --all: Show both listening and non-listening sockets.
  • -l or --listening: Display only listening sockets.
  • -t or --tcp: Display only TCP connections.
  • -u or --udp: Display only UDP connections.
  • -n or --numeric: Show numerical addresses.

Remember to run netstat commands with appropriate privileges (e.g., using sudo) to access detailed information. The above commands provide a snapshot of network-related information, and you can customize them based on your specific requirements.