Back to the command reference

netstat

NetworkFundamentalsReference only

Show connections and listening ports (legacy; prefer ss)

Name: netstat = network statistics

This command is outside what the site lets you practise (mostly distribution-specific or rarely used tools). This page describes how to use it; try it on your own Linux system.

Description

netstat shows connections, listening ports, routing tables and interface statistics (from net-tools). The faster ss has replaced it, but it still appears in many guides and older systems.

Syntax

netstat [OPTION]...

Common options

-t / -uTCP / UDP
-lListening sockets only
-aAll sockets, listening ones too
-nNumeric addresses and ports
-pShow the owning process
-rShow the routing table (like ip route)
-iTraffic statistics per interface
-sStatistics per protocol

Examples

  • $ sudo netstat -tulnp

    Every listening port and its program

    Explain

Related