Linux “ss” Command Examples

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:

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:

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

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:

All the ports of our Linux system are shown below:

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:

The listening sockets of our Linux system are shown below:

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:

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

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:

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

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

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

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

The results of running this command are as follows:

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:

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

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:

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

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:

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:

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.