githubEdit

rectangle-terminalnetstat

🌐 netstat Command in Linux

netstat (network statistics) is a command-line tool for monitoring network connections, routing tables, interfaces, and more. Although deprecated in favor of ss, it's still widely used and useful.


πŸ“‹ Common Options

Option
Description

-a

Show all connections (listening and non-listening)

-t

Show TCP connections

-u

Show UDP connections

-n

Show numerical addresses instead of resolving hostnames

-l

Show only listening sockets

-p

Show the process ID and name of the program using the socket

-r

Display the kernel routing table

-i

Show network interfaces and their statistics

-s

Show summary statistics for each protocol

-c

Continuously display output (refreshes every second)


πŸ§ͺ Examples

Show All Listening and Established Connections

Show TCP Connections Only

Show UDP Connections Only

Show Listening Ports Only

Show Numeric IPs and Ports (No DNS Resolution)

Show Listening TCP Ports with Process Info

Display Routing Table

Display Interface Statistics

Protocol Summary Statistics


πŸ” Continuously Monitor Connections


πŸ›  Tip

  • You may need to use sudo for -p or to view ports used by other users.

  • For modern systems, prefer ss, e.g.:


Last updated