Online Linux Terminal Logo
OnlineLinuxTerminal
Networking & TransferCLI Reference

$netstat

Print network connections, routing tables, interface statistics, and listening ports.

Syntax DefinitionPOSIX standard
netstat [OPTIONS]
Linux Community2.4k Online

Chat with real Linux users, learn new commands & get free cheat sheet PDFs.

Try `netstat` Live in Interactive Sandbox

Zero-install client simulation with real-time feedback.

Open in Fullscreen Workspace↗
bash — terminal

Overview & How netstat Works

`netstat` (Network Statistics) provides comprehensive visibility into incoming and outgoing network connections, listening TCP/UDP ports, routing tables, and interface metrics.

Common Flags & Command Options

Flag / OptionDescription
-tDisplay TCP network connections.
-uDisplay UDP network connections.
-lShow only listening server sockets.
-pShow the PID and program name to which each socket belongs.
-nShow numerical addresses and port numbers instead of resolving hostnames.

Practical Real-World Examples

Example #1Check all listening ports and services
netstat -tuln

Lists all open TCP and UDP ports in numeric format.

Sample Output:
Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN

Frequently Asked Questions

What is the modern replacement for netstat in newer Linux distributions?

The `ss` (Socket Statistics) command from `iproute2` is the faster, modern successor to `netstat`.