Commands
bash
ss -tlnp # listening TCP ports + processes
ss -ulnp # listening UDP ports
ss -tnp # established TCP connections
ss -tanp # all TCP: both listening and established
ss -s # summary: total sockets by type
ss -tnp state established # established only
ss -tnp state time-wait # "stuck" in TIME-WAIT
ss -tlnp '( sport = :80 or sport = :443 )' # who's listening on 80/443
ss -tnp dst 10.0.0.5 # connections to a specific host
ss -tnp 'dport = :5432' # connections to the postgres port
ss -tnp dst 10.0.0.0/24 # to a whole subnet
ss -tonp # with keepalive/retransmit timers
ss -tnp | wc -l # roughly how many active TCP connections