ss command in Linux: sockets and listening ports
Updated November 1, 2026
The ss command shows network sockets: listening ports and open connections.
Syntax
ss [options]Common cases
ss -tuln # listening TCP and UDP ports, numeric
ss -tp # open TCP connections with processes
ss -s # socket summary
ss -tln | grep :22 # is anything listening on port 22Sample output
$ ss -tuln
Netid State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
tcp LISTEN 0 5 0.0.0.0:8080 0.0.0.0:*
$ ss -t
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
ESTAB 0 0 127.0.0.1:47344 127.0.0.1:http-alt
ESTAB 0 0 127.0.0.1:http-alt 127.0.0.1:47344
$ ss -tl
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 5 0.0.0.0:http-alt 0.0.0.0:*How it works: what the flags mean
The
ssflags build up from letters:-tis TCP,-uis UDP,-lis listening only,-nkeeps port numbers numeric (faster and clearer than names),-pshows the process holding the socket (often needs root).ssreplacednetstatand reads socket data straight from the kernel, so it is faster. A socket in the LISTEN state is a server waiting for connections on its port.
Common mistakes
ss -t without -l shows established connections only, and ss -tl shows listening sockets only. The two lists do not overlap: above, ss -t prints two ESTAB rows and no LISTEN row, while port 8080 is being listened on that very second. Empty ss -t output means 'nobody is connected right now', not 'nobody is listening'. ss -ta gives you both lists at once.
The Process column stays quietly empty when the socket belongs to another user. As root ss -tlnp prints users:(("python3",pid=9,fd=3)); as a normal user the same command prints the same row and nothing after 0.0.0.0:*. There is no error, so it is easy to decide the process was not found. To find someone else's process, run it under sudo.
Read the Local Address:Port column in two halves. 0.0.0.0:8080 means 'listening on every address', 127.0.0.1:8080 means 'from this machine only', and the second case explains why a connection from outside is refused while the service is running. Without -n, ss swaps the right half for a name from /etc/services: port 8080 prints as http-alt and 22 as ssh, so ss -tl | grep :8080 finds nothing.
Used in
You need this in the lesson Networking: inspection. The theory is the chapter Networking basics.
See also
Try it
Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.