netstat
NetworkFundamentalsReference onlyShow 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 / -u | TCP / UDP |
| -l | Listening sockets only |
| -a | All sockets, listening ones too |
| -n | Numeric addresses and ports |
| -p | Show the owning process |
| -r | Show the routing table (like ip route) |
| -i | Traffic statistics per interface |
| -s | Statistics per protocol |
Examples
$ sudo netstat -tulnp
Every listening port and its program
Explain