# Basic socket statistics command usage (ss) ###### tags: `linux` `network` ``` # list tcp/udp/unix establised and connected connections # use -e to print extend info ss -t ss -te # also list listening ss -at # list udp ss -ua # no resolve hostname ss -nt # only listening ss -ltn ss -lun # print process name and pid ss -ltp # print summary statistics ss -s # print timer ss -tno # ipv4 or 6 ss -lt -f inet ss -lt4 ss -lt6 # filter tcp connection state ss -t4 state [established | sync-sent | sync-recv | time-wait | closed | close-wait | connected | ... ] # filter address and port ss -t4 state established dport = :22 ss -at '( dport = :22 or sport = :22 )' ss -at '( dst :443 or dst :80 )' ss -at dst :443 or dst :80 ss -at dst 192.168.1.1 ss -at dst 192.168.1.0/24 ss -at dst 192.168.1.1:22 ss -at src 192.168.1.1 sport gt :3000 compare operator: lt , ge , eq , gt , lt , ne compare operator: > , >= , == , < , > , != ```