Identify network issues with SS command in Linux (with examples)

SS command in Linux is used to get various network/socket connection-related information from a Linux system. Previously we had used the Netstat command to perform the same operations but it has been long deprecated & was replaced with the ss command in Linux.

SS command is much faster than netstat & capable of showing much more information than netstat. Those familiar with the Netstat command need not worry as the options used with the ss command are similar to netstat.

In this tutorial, we will learn the usage of the SS command with the help of SS command examples.

(Recommended Read: Learn to use Wget command with 12 examples)

(Also Read: Check Linux filesystem for errors: FSCK command with examples)

SS command examples in Linux

1- Checking all connections

$ ss -a

This will produce all tcp, udp & Unix connections from the system.

2- Checking all tcp or udp or Unix socket connections

$ ss -at

Similarly to list out only the udp connections on our system, we can use the ‘u’ option with ss,

$ ss -au

To only list out Unix socket connections, we can use the ‘x’ option,

$ ss -ax

3- List process id/Process Name with

$ ss -ap

4- List only port number & not the name

$ ss -an

5- Print only listening ports

$ ss -l

6- Print network stats

$ ss -s

7- Print interfaces stats

$ ss -i

8- Display the network routing information

$ ss -r

9- Filtering a single port

$ ss -anp | grep 3306

10- Count the number of connections

$ ss -anp | grep 3306 | wc -l

This will print the number of connections for the port mysql port i.e. 3306.

With this, we end our tutorial on how to use the SS command in Linux with the help of some examples. Please let know if you want us to add some more ss command examples or have any other suggestion or query using the comment box below.

We are giving you exclusive deals to try Linux Servers for free with 100$ credit, check these links to claim your 100$,

DigitalOcean — 100$ free credit & Linode — 100$ free credit

Check some Exclusive Deals, HERE.

Also, check out DevOps Book You should read section.

http://linuxtechlab.com is a beginner friendly website where you can learn Linux Tips & tricks,Scripting, also has lots of tutorials aimed at making Linux easy.