Bash

List Listening Ports

admin by @admin ADMIN
Jun 13, 2026
May 31, 2026
Public
0 0 up · 0 down Sign in to vote
`ss` is the modern netstat — faster, more readable, ships everywhere. Show only listening TCP ports with their owning process.
Bash
Raw
# All TCP listening sockets + the process holding them (needs root for process info)
sudo ss -tlnp

# UDP listeners
sudo ss -ulnp

# Both, summarized
ss -s

# Count active connections by state
ss -tn state established | wc -l

# Find what holds a specific port (alternatives — pick by availability)
sudo ss -tlnp 'sport = :8080'
sudo lsof -i :8080
sudo fuser 8080/tcp

# Legacy netstat — works but deprecated
sudo netstat -tlnp 2>/dev/null
Tags

Save your own code snippets

Create a free account and build your private vault. Share publicly whenever you want.