netstat
🌐 netstat
Command in Linux
netstat
Command in Linuxnetstat
(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
netstat -a
Show TCP Connections Only
netstat -at
Show UDP Connections Only
netstat -au
Show Listening Ports Only
netstat -l
Show Numeric IPs and Ports (No DNS Resolution)
netstat -n
Show Listening TCP Ports with Process Info
sudo netstat -tlnp
Display Routing Table
netstat -r
Display Interface Statistics
netstat -i
Protocol Summary Statistics
netstat -s
🔁 Continuously Monitor Connections
netstat -c
🛠 Tip
You may need to use
sudo
for-p
or to view ports used by other users.For modern systems, prefer
ss
, e.g.:ss -tulnp
Last updated