The `ss` command in Linux is a powerful utility that provides detailed information about network socket connections. It is considered an advanced version of the older `netstat` command, offering more features and flexibility.
In this article, we will explore 25 useful `ss` command examples to monitor network connections on Linux systems.
Syntax
The basic syntax for the `ss` command is as follows:
ss [options] [FILTER]
- Check Linux ss command version
- Display all Listening and Non-Listening Sockets
- Display Socket Memory Usages
- Display Only Listening Sockets
- Run Linux ss command without Any Option
- Display Only TCP Sockets
- Display only TCP Listening Connections
- List all Unix Domain Sockets
- Show Detailed Socket Information
- Suppress Header Information in the Output
- Show Timer Information
- Display Summary Stats
- Display Only IPV4 Sockets
- Display IPV4 Listening Connections Only
- Display IPV6 Listening Connections Only
- Show Socket BPF Filters
- List all UDP Connections
- Show All Processes Using Socket Connection
- Do not Resolve Service Names
- Show Internal TCP Information
- Display Packet Sockets
- Display All Established SSH Connections
- Try to Resolve Numeric Address/Ports
- Display all TCP sockets with process SELinux security contexts
- Check Other Linux SS Command options
Now let’s explore into various examples to understand the capabilities of the `ss` command.
Example 1: Check Linux ss command version
To check the version of the `ss` command, use the following:
ss --version
Example 2: Display all Listening and Non-Listening Sockets
Show all listening and non-listening sockets:
ss -a
Example 3: Display Socket Memory Usages
Check memory usage by each socket connection:
ss -m
Example 4: Display Only Listening Sockets
Show only listening sockets:
ss -l
Example 5: Run Linux ss command without Any Option
Check all active socket and packet connections:
ss
Example 6: Display Only TCP Sockets
Show only TCP socket connections:
ss -t
Example 7: Display only TCP Listening Connections
Check all listening TCP connections:
ss -lt
Example 8: List all Unix Domain Sockets
List connections in Unix Domain Sockets type:
ss -x
Example 9: Show Detailed Socket Information
Check detailed information about socket connections:
ss -e
Example 10: Suppress Header Information in the Output
Suppress header information in the `ss` command output:
ss -H
Example 11: Show Timer Information
Check timer information:
ss -o
Example 12: Display Summary Stats
Check the summary of socket state:
ss -s
Example 13: Display Only IPV4 Sockets
Show all IPV4 socket connections:
ss -4
Example 14: Display IPV4 Listening Connections Only
Display all IPV4 listening connections:
ss -l4
Example 15: Display IPV6 Listening Connections Only
Show all listening IPV6 connections:
ss -l6
Example 16: Show Socket BPF Filters
List all Socket BPF Filters:
ss -b
Example 17: List all UDP Connections
Check all UDP listening connections:
ss -lu
Example 18: Show All Processes Using Socket Connection
Show all processes using sockets:
ss -p
Example 19: Do not Resolve Service Names
Do not resolve service names:
ss -n
Example 20: Show Internal TCP Information
Show internal TCP information:
ss -i
Example 21: Display Packet Sockets
Display packet sockets:
ss -0
Example 22: Display All Established SSH Connections
Display all established SSH connections:
ss -o state established '( dport = :ssh or sport = :ssh )'
Example 23: Try to Resolve Numeric Address/Ports
Try to resolve numeric addresses or ports:
ss -r
Example 24: Display all TCP sockets with process SELinux security contexts
Display all TCP sockets with process SELinux security contexts:
ss -t -a -Z
Example 25: Check Other Linux SS Command options
Check all available options for the `ss` command:
ss --help
These examples cover a range of scenarios, from basic socket information to more advanced filtering and analysis. The `ss` command is a versatile tool for monitoring and troubleshooting network connections on Linux systems.
You may also like:- [Solution] Missing logstash-plain.log File in Logstash
- Understanding Netstat – The Network Monitoring Tool
- Top 40 Useful Linux Command Snippets
- Using Elasticsearch Ingest Pipeline to Copy Data from One Field to Another
- Top 10 Useful Windows Commands
- Essential Commands For Process Management in Kali Linux
- How To Install Python 2.7.18 From The Source
- How To Parse SSH Authentication Logs with Logstash
- A Comprehensive Guide to File System Commands in Linux
- Essential File Compression Commands in Linux