Note
ss
is the replacement program, replacing deprecatednetstat
(similar toip
replacingifconfig
).
terminology
socket
: TCP/UDP/UNIXlistening
:non-listening
:
flags
-t
: TCP-u:
: UDP-l
: display listening sockets-a
: display both listening and non-listening-p
: show process name-n
: show numeric IP addresses-s
: show statistics-c
: print continuously-r
: print kernel (internal/localhost) routing table-o
: show timer information-4
: show only IPv4 connections-6
: show only IPv6 connections
useful commands
ss
: by default displays open, non-listening sockets (TCP/UDP/UNIX) that have established connectionsss -tulpn
: show TCP and UDP with listening ports, process names, and numeric IP addressesss -co
: print default connection information continuously, with timer informationnetstat -co --protocol=inet,inet6
: continuously monitor IPv4 and IPv6 connections with timer informationss -an | grep ssh
: find out what port a particular service is usingss -an | grep ':80'
: find out what service is using a particular port