25 Useful Linux SS Command Examples to Monitor Network Connections

ss command examples techhyme

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]
  1. Check Linux ss command version
  2. Display all Listening and Non-Listening Sockets
  3. Display Socket Memory Usages
  4. Display Only Listening Sockets
  5. Run Linux ss command without Any Option
  6. Display Only TCP Sockets
  7. Display only TCP Listening Connections
  8. List all Unix Domain Sockets
  9. Show Detailed Socket Information
  10. Suppress Header Information in the Output
  11. Show Timer Information
  12. Display Summary Stats
  13. Display Only IPV4 Sockets
  14. Display IPV4 Listening Connections Only
  15. Display IPV6 Listening Connections Only
  16. Show Socket BPF Filters
  17. List all UDP Connections
  18. Show All Processes Using Socket Connection
  19. Do not Resolve Service Names
  20. Show Internal TCP Information
  21. Display Packet Sockets
  22. Display All Established SSH Connections
  23. Try to Resolve Numeric Address/Ports
  24. Display all TCP sockets with process SELinux security contexts
  25. 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

SS Command Ubuntu Linux Techhyme

Example 2: Display all Listening and Non-Listening Sockets

Show all listening and non-listening sockets:

ss -a

SS Command Ubuntu Linux Techhyme

Example 3: Display Socket Memory Usages

Check memory usage by each socket connection:

ss -m

SS Command Ubuntu Linux Techhyme

Example 4: Display Only Listening Sockets

Show only listening sockets:

ss -l

SS Command Ubuntu Linux Techhyme

Example 5: Run Linux ss command without Any Option

Check all active socket and packet connections:

ss

SS Command Ubuntu Linux Techhyme

Example 6: Display Only TCP Sockets

Show only TCP socket connections:

ss -t

SS Command Ubuntu Linux Techhyme

Example 7: Display only TCP Listening Connections

Check all listening TCP connections:

ss -lt

SS Command Ubuntu Linux Techhyme

Example 8: List all Unix Domain Sockets

List connections in Unix Domain Sockets type:

ss -x

SS Command Ubuntu Linux Techhyme

Example 9: Show Detailed Socket Information

Check detailed information about socket connections:

ss -e

SS Command Ubuntu Linux Techhyme

Example 10: Suppress Header Information in the Output

Suppress header information in the `ss` command output:

ss -H

SS Command Ubuntu Linux Techhyme

Example 11: Show Timer Information

Check timer information:

ss -o

SS Command Ubuntu Linux Techhyme

Example 12: Display Summary Stats

Check the summary of socket state:

ss -s

SS Command Ubuntu Linux Techhyme

Example 13: Display Only IPV4 Sockets

Show all IPV4 socket connections:

ss -4

SS Command Ubuntu Linux Techhyme

Example 14: Display IPV4 Listening Connections Only

Display all IPV4 listening connections:

ss -l4

SS Command Ubuntu Linux Techhyme

Example 15: Display IPV6 Listening Connections Only

Show all listening IPV6 connections:

ss -l6

SS Command Ubuntu Linux Techhyme

Example 16: Show Socket BPF Filters

List all Socket BPF Filters:

ss -b

SS Command Ubuntu Linux Techhyme

Example 17: List all UDP Connections

Check all UDP listening connections:

ss -lu

SS Command Ubuntu Linux Techhyme

Example 18: Show All Processes Using Socket Connection

Show all processes using sockets:

ss -p

SS Command Ubuntu Linux Techhyme

Example 19: Do not Resolve Service Names

Do not resolve service names:

ss -n

SS Command Ubuntu Linux Techhyme

Example 20: Show Internal TCP Information

Show internal TCP information:

ss -i

SS Command Ubuntu Linux Techhyme

Example 21: Display Packet Sockets

Display packet sockets:

ss -0

SS Command Ubuntu Linux Techhyme

Example 22: Display All Established SSH Connections

Display all established SSH connections:

ss -o state established '( dport = :ssh or sport = :ssh )'

SS Command Ubuntu Linux Techhyme

Example 23: Try to Resolve Numeric Address/Ports

Try to resolve numeric addresses or ports:

ss -r

SS Command Ubuntu Linux Techhyme

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

SS Command Ubuntu Linux Techhyme

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:

Related Posts

Leave a Reply