ss command (Linux / bash / sh / zsh)
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 / option | Meaning |
|---|---|
| -t | Show TCP sockets. |
| -u | Show UDP sockets. |
| -l | Show listening sockets. |
| -n | Keep addresses and ports numeric. |
| -p | Show 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.
Related commands
- netstatDisplay legacy network connections, routes, and interface statistics.
- pingTest IP reachability and measure round-trip response time.
- ipconfigDisplay and manage Windows IP configuration and DNS client state.
- pingTest reachability and measure response time with ICMP echo requests.
- curlTransfer data to or from URLs using many network protocols.
- sshOpen a secure remote shell or run a command over SSH.
- Invoke-WebRequestSend HTTP and HTTPS requests and return response metadata and content.
- netstatDisplay active connections, listening ports, routing data, and protocol statistics.
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.