Skip to main content

ss command

Detailed Explanation

The ss (socket statistics) command is a modern, faster replacement for the netstat command. It dumps socket statistics and allows displaying information in a similar fashion to netstat. It can display more TCP and state information than other tools, making it highly valuable for system administrators and developers.

Basic Syntax

ss [options] [FILTER]

Common Flags/Options

OptionDescription
-tDisplay TCP sockets.
-uDisplay UDP sockets.
-lDisplay listening sockets.
-aDisplay all sockets (listening and non-listening).
-nDo not resolve service names (show numeric port numbers).
-pShow process using the socket.

Real-world Examples

List all listening TCP connections with numeric ports and process names:

sudo ss -tlnp

List all established TCP connections:

ss -t -a state established

List all UDP sockets:

ss -ua

Show sockets connected to a specific destination IP:

ss dst 192.168.1.1

Show sockets matching a specific source port:

ss sport = :80