Skip to main content

Module 9: Networking

Lesson 81: ss Command

In this lesson, you'll learn how to use the ss command to display network socket-related information on a Linux system.

ss command is a tool that is used for displaying network socket-related information on a Linux system.

The tool displays more detailed information than the netstat command that is used for displaying active socket connections.

Let's explore how the ss command is used to display varied socket connection information in Linux.

ss Command Syntax

$ ss [OPTIONS] [FILTER]

ss Command Options

Option Description
-a List all listening and non-listening sockets
-l Display listening sockets only
-t Display TCP connections
-u Display UDP connections
-lt Display all listening TCP connections
-lu Display all listening UDP connections
-p Display the process IDs (PIDs) using the sockets
-s Display summary statistics
-4 Display IPv4 socket connections
-6 Display IPv6 socket connections

1. List All Connections

The basic ss command without any options simply lists all the connections regardless of the state they are in.

$ ss
Netid  State   Recv-Q  Send-Q  Local Address:Port    Peer Address:Port
tcp    ESTAB   0       0       192.168.1.10:ssh      192.168.1.1:52341
tcp    ESTAB   0       0       192.168.1.10:ssh      192.168.1.2:49812
u_str  ESTAB   0       0       /run/systemd/journal/stdout 22001 * 22000

2. List Listening and Non-listening Ports

You can retrieve a list of both listening and non-listening ports using the -a option as shown below.

$ ss -a
Netid  State    Recv-Q  Send-Q  Local Address:Port       Peer Address:Port
tcp    LISTEN   0       128     0.0.0.0:ssh              0.0.0.0:*
tcp    LISTEN   0       128     0.0.0.0:http             0.0.0.0:*
tcp    ESTAB    0       0       192.168.1.10:ssh         192.168.1.1:52341
udp    UNCONN   0       0       0.0.0.0:bootpc           0.0.0.0:*

3. List Listening Sockets

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’