NETSTAT Commands Cheatsheet — Essential Reference

Netstat (network statistics) is a command-line utility that displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. It's a fundamental tool for network troubleshooting and performance monitoring.

Last updated: 2026-06-11

RECOMMENDED

Master NETSTAT with Top Reference Books

Level up your DevOps skills. Find the best guide books and cheatsheet references for your engineering stack.

Search on Amazon →

Commands

Command Description Example
netstat -a Display all active connections and listening ports. netstat -a
netstat -at Display all active TCP connections. netstat -at
netstat -au Display all active UDP connections. netstat -au
netstat -l Display only listening sockets. netstat -l
netstat -lt Display only listening TCP sockets. netstat -lt
netstat -lp Display listening sockets with the process ID (PID) and program name. netstat -lp
netstat -tulpn Display TCP and UDP listening ports with PID/program name and numerical addresses (no DNS lookup). This is a very common and useful combination. netstat -tulpn
netstat -r Display the kernel IP routing table. netstat -r
netstat -s Display network statistics for each protocol. netstat -s
netstat -i Display a table of all network interfaces. netstat -i
netstat -an | grep ':80' Filter active connections to show only those on port 80 (HTTP). netstat -an | grep ':80'

Pro Tips

  • Combine flags for more specific output, e.g., `netstat -tulpn` is a powerful combination.
  • Use `grep` to filter `netstat` output for specific ports, IPs, or states.
  • The `-n` flag (numerical addresses) is crucial for performance as it avoids DNS lookups, which can be slow.
  • Understand the 'State' column (e.g., LISTEN, ESTABLISHED, TIME_WAIT) to diagnose connection issues.
  • On modern Linux systems, `ss` is often recommended as a faster and more feature-rich replacement for `netstat`.

Frequently Asked Questions

What is netstat used for?

Netstat is primarily used to inspect network connections, routing tables, and interface statistics. It helps in identifying open ports, active connections, and potential network issues or unauthorized activity.

How do I install netstat?

Netstat is typically part of the `net-tools` package on Linux distributions. On Debian/Ubuntu, you can install it with `sudo apt-get install net-tools`. On CentOS/RHEL, use `sudo yum install net-tools` or `sudo dnf install net-tools`. On Windows, it's usually available by default.