ss
(“socket statistics”) is a *nix tool for listing socket informaion, e.g., which TCP/UDP ports are in use.
Difference between
ss
andnetstat
Common oneliners (may require sudo to see process name and PID):
Common options:
- Filter by listen
-l
,--listening
: list listening sockets (i.e., socket being listened on by a process)-a
,--all
: list all sockets
- Filter by protocol
-t
,--tcp
: list TCP sockets-u
,--udp
: list UDP sockets- Note that
ss -ltu
matches sockets on either a TCP or UDP port
- Display additional data
-p
,--processes
: list PID that is using (listening on) the port-e
,--extended
: show more information about the socket & process-n
,--numeric
: show port as number instead of service-r
,--resolve
: resolve IP address into hostname