Linux “ss” Command Examples

3

The “ss” is a built-in Linux command used to display detailed information about the network sockets. You can use different options with this command to display the kind of information that you want. We will briefly talk about some examples of using the “ss” command in Linux in today’s guide.

Basic Syntax of the “ss” Command and Its Help Manual

The basic syntax of the command under discussion is shown below:

There are different available options that you can use with the “ss” command. You can check out these options by accessing the “help” manual of “ss” with the following command:

You can see the “help” manual of the “ss” command in the image shown below:

Examples of the “ss” Command in Linux

The examples of the “ss” command in Linux are discussed below:

linux “ss” command examples Linux “ss” Command Examples 1623001430 77 Linux ss Command Examples

Example 1: Display All the Connections
If you want to list down all the connections of your Linux system, you can run the “ss” command without any options in the following manner:

linux “ss” command examples Linux “ss” Command Examples 1623001430 718 Linux ss Command Examples

All the connections of our Linux system are displayed in the image below:

linux “ss” command examples Linux “ss” Command Examples 1623001431 770 Linux ss Command Examples

Example 2: Display All the Ports
You can display all the ports regardless of whether they are listening or not by using the following variation of the “ss” command in Linux:

linux “ss” command examples Linux “ss” Command Examples 1623001431 181 Linux ss Command Examples

All the ports of our Linux system are shown below:

linux “ss” command examples Linux “ss” Command Examples 1623001432 679 Linux ss Command Examples

Example 3: Display the Listening Sockets Only
If you want to display only the listening sockets on the terminal, you can use the “ss” command in the following manner:

linux “ss” command examples Linux “ss” Command Examples 1623001432 719 Linux ss Command Examples

The listening sockets of our Linux system are shown below:

linux “ss” command examples Linux “ss” Command Examples 1623001433 486 Linux ss Command Examples

Example 4: Display All the UDP Connections
We know that we either have UDP connections or TCP connections. If you want to list down all the UDP connections, you should use the “ss” command in the following manner:

linux “ss” command examples Linux “ss” Command Examples 1623001433 446 Linux ss Command Examples

All the UDP connections of our Linux system are as follows:

linux “ss” command examples Linux “ss” Command Examples 1623001434 334 Linux ss Command Examples

Example 5: Display All the Listening UDP Connections
If you only want to list down those UDP connections that are currently listening, you can use the following version of the “ss” command:

linux “ss” command examples Linux “ss” Command Examples 1623001434 936 Linux ss Command Examples

All the listening UDP connections of our Linux system are shown below:

linux “ss” command examples Linux “ss” Command Examples 1623001435 66 Linux ss Command Examples

Example 6: Display All the TCP Connections
Similarly, you can also list down all the TCP connections in the following manner:

linux “ss” command examples Linux “ss” Command Examples 1623001435 594 Linux ss Command Examples

All the TCP connections of our Linux system are shown below:

linux “ss” command examples Linux “ss” Command Examples 1623001436 385 Linux ss Command Examples

Example 7: Display All the Listening TCP Connections
The listening TCP connections of the Linux system can be displayed with the following command:

linux “ss” command examples Linux “ss” Command Examples 1623001436 195 Linux ss Command Examples

The results of running this command are as follows:

linux “ss” command examples Linux “ss” Command Examples 1623001437 846 Linux ss Command Examples

Example 8: Display a Summary of All the Connections
You can even list down the statistics summary of all the connections of your system by using the “ss” command in the following manner:

linux “ss” command examples Linux “ss” Command Examples 1623001437 273 Linux ss Command Examples

The statistics summary of all the connections of our Linux system is shown below:

linux “ss” command examples Linux “ss” Command Examples 1623001438 227 Linux ss Command Examples

Example 9: Display the Processes Using the Sockets
If you want to display the processes corresponding to all the connection sockets, then you can execute the “ss” command in the following manner:

linux “ss” command examples Linux “ss” Command Examples 1623001438 527 Linux ss Command Examples

The output of this variation of the “ss” command is as follows:

linux “ss” command examples Linux “ss” Command Examples 1623001439 961 Linux ss Command Examples

Example 10: Display the Connections Corresponding to a Specific Internet Protocol
You can even choose to display all the IPv4 or IPv6 connections. For displaying only the IPv4 connections, you can execute the “ss” command as follows:

linux “ss” command examples Linux “ss” Command Examples 1623001439 80 Linux ss Command Examples

If you want to display all the IPv6 connections, you can replace “-4” with “-6”. The output of this variant of the “ss” command is shown below:

linux “ss” command examples Linux “ss” Command Examples 1623001440 101 Linux ss Command Examples

Conclusion

We nearly covered all the example use cases of the “ss” command in Linux in this article. However, you can explore the usage of this command further by reviewing its Help Manual.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More