Catalog / Netstat Command Cheatsheet
Netstat Command Cheatsheet
A comprehensive cheat sheet for the `netstat` command, covering its common options and usage for network troubleshooting and monitoring. This cheat sheet provides quick references for displaying network connections, routing tables, interface statistics, and more.
Basic Netstat Usage
Displaying Active Connections
|
Shows active connections. |
|
Displays all active connections and listening ports. |
|
Shows only TCP connections. |
|
Shows only UDP connections. |
|
Displays UNIX domain sockets. |
|
Displays all TCP connections, including listening sockets. |
Displaying Network Interfaces
|
Shows the network interfaces and their statistics. |
|
Displays extended network interface information. |
|
Shows numeric network addresses instead of resolving hostnames. |
|
Continuously display network statistics, updating every second. |
Displaying Routing Table
|
Shows the kernel routing table. |
|
Displays the routing table numerically. |
|
Alternative to |
Advanced Netstat Options
Combining Options
|
Shows all TCP connections with numeric addresses. |
|
Displays all connections and listening ports with the associated PID and program name (requires sudo). |
|
Listens for TCP and UDP ports with PID and program name. |
|
Shows all listening TCP and UDP ports with PID and program name. |
Filtering Connections
|
Shows connections on port 80 (HTTP). |
|
Shows connections on port 443 (HTTPS). |
|
Shows established connections. |
|
Shows connections to/from the IP address 192.168.1.100. |
Displaying Multicast Group Memberships
|
Shows multicast group memberships. |
Netstat Output Interpretation
Connection States
ESTABLISHED: The socket has an established connection. |
Column Descriptions
Proto: The protocol used (TCP, UDP, etc.). |
Numeric vs. Symbolic Addresses
By default, Using the |
Netstat Examples
Troubleshooting Network Issues
To identify which process is listening on a specific port (e.g., port 80):
To check the number of established connections to a web server:
|
Monitoring Network Traffic
To continuously monitor network interface statistics:
(This command updates the interface statistics every 1 second.)
|
Replacing Netstat (Alternatives)
|