Networking

netstat & ss CLI

netstat and ss commands for network diagnostics.

30 commands
Windows MacOS Linux
#network-diagnostics #system

List Connections

Show all TCP connections
ss -t -a
Show all UDP connections
ss -u -a
Show all connections in numeric format
netstat -an
Display socket usage summary
ss -s
Show all TCP connections numerically
netstat -ant
Show all established connections
ss

Listening Ports

Show TCP listening ports with process names
ss -tlnp
Show UDP listening ports with process names
ss -ulnp
List TCP listening ports with PIDs
netstat -tlnp
List UDP listening ports with PIDs
netstat -ulnp
Show all listening sockets numerically
ss -ln

Statistics

Show socket statistics summary
ss -s
Display protocol-level statistics
netstat -s
Show TCP-only statistics
netstat -st
Show UDP-only statistics
netstat -su
Show TCP sockets with internal info
ss -ti

Filtering

Show only established TCP connections
ss -t state established
Filter connections by destination subnet
ss -t dst 192.168.1.0/24
Show connections from source port 443
ss -t sport = :443
Show connections to destination port 80
ss -t dport = :80
Show connections in TIME-WAIT state
ss -t state time-wait
Filter output for port 80 connections
netstat -an | grep ':80 '

Process Info

Show listening ports with process info
ss -tlp
Show processes connected to port 443
ss -p dst :443
List all listeners with PID and program name
netstat -tulpn
Show established connections with process info
ss -tnp state established
Find connections owned by nginx
netstat -anp | grep nginx

Quick Commands

Show all TCP listening ports with process names
ss -tlnp
List all listening ports with PIDs and programs
netstat -tulpn
Display only established TCP connections
ss -t state established