Operations 5 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Socket Inspection with the ss Command – Quick Options and Examples

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:

# ss
ss command output example
ss command output example

Suppress Header Line

Use the -H option to hide the column headers:

# ss -H
ss -H output
ss -H output

Filter by Protocol

TCP only: ss -t UDP only: ss -u UNIX sockets only:

ss -x
# ss -t
# ss -u
# ss -x

Show Only Listening Sockets

The -l flag restricts output to sockets in the LISTEN state:

# ss -l
ss -l output
ss -l output

Display 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   0
ss -s summary
ss -s summary

Show Only IPv4 or IPv6 Listening Sockets

IPv4 listening sockets: ss -4 -l IPv6 listening sockets:

ss -6 -l
# ss -4l
# ss -6l
ss -4l output
ss -4l output
ss -6l output
ss -6l output

Prevent DNS Resolution

Use -n to keep IP addresses from being resolved to hostnames (note that port numbers will also stay numeric):

# ss -n -4l
ss -n -4l output
ss -n -4l output

These 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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

networkLinuxSocketcommand-linesssystem-administration
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.