Skip to main content

Command referencess

ss command (Linux / bash / sh / zsh)

Linuxbashshzshnetworkintermediate

What it does

Inspect network sockets, listeners, and connection statistics. When people search for the ss command linux ports, they usually want ss's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Inspect network sockets, listeners, and connection statistics.

Syntax

ss [OPTION]... [FILTER]

Common options

Flag / optionMeaning
-tShow TCP sockets.
-uShow UDP sockets.
-lShow listening sockets.
-nKeep addresses and ports numeric.
-pShow associated processes when permitted.

Practical examples

Listening TCP ports

ss -ltn

Lists numeric TCP listeners.

Processes using ports

sudo ss -ltnp

Adds process information to TCP listeners.

Established SSH

ss -tn state established '( sport = :ssh or dport = :ssh )'

Filters established SSH connections.

Linux ↔ Windows equivalent

Closest match: netstat (Windows / CMD). Display active connections, listening ports, routing data, and protocol statistics.

Common mistakes

  • Forgetting `-l` and missing listening sockets.
  • Expecting process details without sufficient privileges.

FAQ

What does ss do in Linux?

Inspect network sockets, listeners, and connection statistics.

How do I use ss from the terminal?

Start with `ss [OPTION]... [FILTER]`, then choose only the options needed for the task.

What is a practical ss example?

Try `ss -ltn` — Lists numeric TCP listeners.

Can I use ss in a shell script?

Yes. ss works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.