ss is a command-line utility used to investigate sockets in a Linux system. A socket is an endpoint for sending and receiving data across a network, and can be used by various network services and applications to communicate with each other.
The ss command provides an alternative to the netstat command, which is used to display information about network connections and routing tables. However, ss provides more detailed information about sockets and is generally faster and more efficient than netstat.
ss can be used to display a variety of information about sockets, including the state of the socket, the protocol used, the local and remote addresses, and the amount of data transmitted or received. The command also supports a wide range of filtering options, allowing users to selectively display sockets based on a variety of criteria, such as the socket state or the application that created the socket.
ss Command Examples
1. Show all TCP/UDP/RAW/UNIX sockets:
# ss -a -t|-u|-w|-x
2. Filter TCP sockets by states, only/exclude:
# ss state/exclude bucket/big/connected/synchronized/...
3. Show all TCP sockets connected to the local HTTPS port (443):
# ss -t src :443
4. Show all TCP sockets listening on the local 8080 port:
# ss -lt src :8080
5. Show all TCP sockets along with processes connected to a remote ssh port:
# ss -pt dst :ssh
6. Show all UDP sockets connected on specific source and destination ports:
# ss -u 'sport == :source_port and dport == :destination_port'
7. Show all TCP IPv4 sockets locally connected on the subnet 192.168.0.0/16:
# ss -4t src 192.168/16
Summary
In summary, ss is a powerful and flexible tool for investigating sockets in a Linux system. It provides detailed information about sockets and supports a wide range of filtering options, making it a valuable tool for network troubleshooting and analysis.