The ss command is used to show socket statistics. It can display stats for PACKET sockets, TCP sockets, UDP sockets, DCCP sockets, RAW sockets, Unix domain sockets, and more.
It allows showing information similar to the netstat command. SS can provide information about:
-All TCP sockets.
-All UDP sockets.
-All established ssh/http/https connections.
-All local processes connected to the server.
-Filtering by state (such as connected, synchronized, SYN-RECV, SYN-SENT,TIME-WAIT), addresses and ports.
-All the TCP sockets in state FIN-WAIT1 and more.
List currently established, closed, orphaned and waiting TCP sockets:
~# ss -s
Display all open network ports:
~# ss -l
See the process named using open socket:
~# ss -pl
Find out who is responsible for opening socket / port #21:
~# ss -lp | grep 21
“init” (PID #1579) is responsible for opening port #21. You can get more on the process by going to:
~# cd /proc/1579
~# ls -l
Display all TCP sockets:
~# ss -t -a
Display all UDP sockets:
~# ss -u -a
Display all RAW sockets:
~# ss -w -a
Display all UNIX sockets:
~# ss -x -a
Display all established SMTP connections:
~# ss -o state established ‘( dport = :smtp or sport = :smtp )’
Display all established HTTP connections:
~# ss -o state established ‘( dport = :http or sport = :http )’