Master Linux Socket Inspection with the ss Command – Quick Options and Examples
This guide explains how to use the Linux ss command to view socket information, covering basic usage, options for filtering TCP/UDP/UNIX sockets, suppressing headers, showing listening sockets, summarizing statistics, and preventing DNS resolution, with concrete command examples and output screenshots.
If you need to inspect socket information on a Linux system, the first tool that comes to mind is often netstat, but ss provides more detailed and faster output.
Show All Established Connections
Running ss without any options lists every established socket:
# ssSuppress Header Line
Use the -H option to hide the column headers:
# ss -HFilter by Protocol
TCP only: ss -t UDP only: ss -u UNIX sockets only:
ss -x # ss -t # ss -u # ss -xShow Only Listening Sockets
The -l flag restricts output to sockets in the LISTEN state:
# ss -lDisplay Summary Statistics
Adding -s provides a concise summary of socket usage:
# ss -s
Total: 156
TCP: 3 (estab 1, closed 0, orphaned 0, timewait 0)
Transport Total IP IPv6
RAW 1 0 1
UDP 3 2 1
TCP 3 2 1
INET 7 4 3
FRAG 0 0 0Show Only IPv4 or IPv6 Listening Sockets
IPv4 listening sockets: ss -4 -l IPv6 listening sockets:
ss -6 -l # ss -4l # ss -6lPrevent DNS Resolution
Use -n to keep IP addresses from being resolved to hostnames (note that port numbers will also stay numeric):
# ss -n -4lThese options allow you to tailor the ss output to the exact information you need, making it a powerful replacement for netstat in everyday Linux network troubleshooting.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
