Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Use the Linux ss (Socket Statistics) Command

Use ss to see open sockets, listening ports and connections, and replace the old netstat.

How-To Guides2 min read6 screenshots

What is ss

ss (socket statistics) shows network sockets: connections, listening ports and the state of each. It is faster than the old netstat and gives more detail. Read the manual with:

man ss
The ss manual page

Common options

CommandWhat it shows
ssEstablished connections
ss -aAll sockets, listening and not
ss -lOnly listening sockets
ss -tTCP sockets
ss -uUDP sockets
ss -ltListening TCP sockets
ss -luListening UDP sockets
ss -pThe process that uses each socket
ss -nNumbers, no name lookup (faster)
ss -sA summary of statistics
ss -4IPv4 sockets only
ss -6IPv6 sockets only

Example 1: List connections

ss
Basic ss output

Example 2: List all sockets

ss -a
All connections

Example 3: List listening sockets

ss -l
Listening sockets

Example 4: IPv4 or IPv6 only

ss -4
IPv4 sockets
ss -6

Example 5: Summary

ss -s
The summary of sockets

It shows the total number of sockets and counts for TCP, UDP and others.

Practical examples

Find which program listens on which port (needs root to see all):

sudo ss -tulpn

Check who uses port 80:

sudo ss -tlnp | grep :80

Show connections to a remote address:

ss -t dst 203.0.113.5

Filter by state:

ss -t state established

Count connections to port 443:

ss -tn sport = :443 | wc -l

Quick recap

  • ss -tulpn is the best command to see listening ports with their programs.
  • ss -s gives a quick summary.