On this page 13 sections
  1. What ss shows
  2. The most useful command
  3. Listening ports
  4. Show associated processes
  5. Why -n matters
  6. Active TCP connections
  7. Filter established connections
  8. Common TCP states
  9. Filter by port
  10. Quick filtering with grep
  11. IPv4 and IPv6
  12. Understand bind addresses
  13. Useful system enumeration command
01

What ss shows

ss displays socket information from the Linux networking stack. It is commonly used to identify listening services, active TCP connections, UDP sockets and the processes associated with network ports.

Show sockets
ss
02

The most useful command

A common combination is -lntp: listening sockets, numeric addresses, TCP and process information.

Listening TCP ports and processes
sudo ss -lntp
03

Listening ports

-l limits output to listening sockets. Combine it with t for TCP or u for UDP.

All listening sockets
ss -l
Listening TCP ports
ss -lnt
Listening UDP ports
ss -lnu
TCP and UDP
ss -lntu
04

Show associated processes

-p shows which process owns the socket when permissions allow it.

Ports with processes
sudo ss -lntup
05

Why -n matters

-n prevents service-name and hostname resolution. Instead of displaying ssh or https, ss shows the raw port numbers 22 and 443. This is usually clearer during troubleshooting.

Numeric TCP sockets
ss -nt
06

Active TCP connections

Without -l, ss can display established and transitional network connections.

TCP connections
ss -nt
TCP connections and processes
sudo ss -ntp
07

Filter established connections

Socket states can be filtered directly to focus on active sessions.

Established TCP connections
ss -nt state established
Listening TCP sockets
ss -nt state listening
08

Common TCP states

LISTEN means a service is waiting for connections. ESTABLISHED represents an active connection. TIME-WAIT appears after a connection closes while TCP waits before fully releasing the socket. SYN-SENT and SYN-RECV represent connection establishment.

09

Filter by port

ss supports expressions that filter sockets by source or destination port.

Port 22
ss -ntp '( sport = :22 )'
Destination port 443
ss -ntp '( dport = :443 )'
10

Quick filtering with grep

For quick interactive checks, ss output is often piped into grep.

Find port 443
sudo ss -lntp | grep ":443"
Find SSH
sudo ss -lntp | grep ":22"
11

IPv4 and IPv6

-4 restricts output to IPv4 and -6 restricts it to IPv6.

IPv4 listening ports
ss -4lnt
IPv6 listening ports
ss -6lnt
12

Understand bind addresses

A service bound to 127.0.0.1 is normally accessible only locally. 0.0.0.0 means the service listens on all IPv4 interfaces. [::] commonly indicates all IPv6 interfaces and may also accept IPv4 depending on system configuration.

Inspect listening interfaces
sudo ss -lntp
13

Useful system enumeration command

During Linux troubleshooting or authorised host enumeration, this command gives a fast overview of exposed network services and their processes.

Network service overview
sudo ss -lntup