Skip to content

The ss command

The ss command lists network sockets…

The ss command lists network sockets; ss -tlnp shows which programs are listening on which TCP ports, the first thing to check when a service doesn’t answer.

Taught in Advanced, lesson 45; more in Ninja

A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.

Usage

ss -tlnp
ss -tuln
ss -t

Show network sockets: who is listening on which port. Lists network connections and listening ports. ss -tlnp answers "what is listening on this machine?": t for TCP, l for listening, n for numbers instead of names, p for the program (other users’ programs need sudo). A server you can’t reach should appear here; if it listens on 127.0.0.1 only, other machines can’t connect. In this practice shell the network is a simulation inside your browser: the machines web, db and router and the website example.com are pretend, and nothing leaves your device.

In the practice terminal:A simulation: web, db, router and example.com are pretend machines inside your browser, and nothing leaves your device. Nothing listens on your laptop yet, so the examples log in to web first.

How to use ss

Which ports are open: ss -tln

-t is TCP, -l listening sockets only, -n numbers instead of names. 0.0.0.0:80 listens on every address; 127.0.0.1:3000 only for programs on the same machine.

ssh web
The authenticity of host 'web (10.0.0.10)' can't be established.
ED25519 key fingerprint is SHA256:aaVFThjlH4/WIvuW5JbeDsUSex1ZSOHtUS3pZXDPB10.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'web' (ED25519) to the list of known hosts.
learner@web's password: 
Welcome to Ubuntu 24.04 LTS (practice web server web)

This is a pretend machine inside your browser. Type exit to go back to sandbox.

Last login: Mon Jan 12 06:39:27 2026 from 10.0.0.5
ss -tln
State  Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0      511            0.0.0.0:22 0.0.0.0:*
LISTEN 0      511            0.0.0.0:80 0.0.0.0:*
LISTEN 0      511        127.0.0.1:3000 0.0.0.0:*

Which program has a port: ss -tlnp

Still on web: -p adds the program and its PID. Other users’ programs show only with sudo.

sudo ss -tlnp
[sudo] password for learner: 
State  Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0      511            0.0.0.0:22         0.0.0.0:* users:(("sshd",pid=701,fd=3))
LISTEN 0      511            0.0.0.0:80         0.0.0.0:* users:(("nginx",pid=812,fd=6),("nginx",pid=813,fd=6),("nginx",pid=814,fd=6))
LISTEN 0      511        127.0.0.1:3000         0.0.0.0:* users:(("node",pid=921,fd=3))

Look for one port

On web, as above.

sudo ss -tlnp | grep :80
[sudo] password for learner: 
LISTEN 0      511            0.0.0.0:80         0.0.0.0:* users:(("nginx",pid=812,fd=6),("nginx",pid=813,fd=6),("nginx",pid=814,fd=6))

UDP as well: ss -tuln

On web, as above.

ss -tuln
Netid State  Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp   LISTEN 0      511            0.0.0.0:22 0.0.0.0:*
tcp   LISTEN 0      511            0.0.0.0:80 0.0.0.0:*
tcp   LISTEN 0      511        127.0.0.1:3000 0.0.0.0:*

Options

-tTCP
-uUDP
-llistening sockets
-aall, listening and connected
-nnumbers, not names
-pthe program using each
-sa summary

Questions about ss

What is the difference between ss and netstat?

ss replaced netstat on Linux: ss -tlnp shows what netstat -tlnp used to. netstat is in the net-tools package, which many systems no longer install.

What does 127.0.0.1 mean in ss?

The program accepts connections only from the same machine. 0.0.0.0 (or *) means every address, so other machines can connect if the firewall allows it.

Why is the Process column empty?

ss shows other users’ programs only to root. Run sudo ss -tlnp.

Learn it step by step

Every everyday command on one page, to print or keep open: the Linux commands cheat sheet.