Linux Commands

List All Open Sockets Listening on a Linux Machine

A socket in networking serves as a communication endpoint. It provides a connection between two entities that wish to communicate with each other within a network. Sockets are used on the TCP/IP stack transport layer and are used to send and receive the data packets. In today’s article, we will explain to you the different methods of listing down all the open sockets that are listening on a Linux Mint 20 machine.

Methods of Listing Down all the Open Sockets Listening on a Linux Mint 20 Machine:

For listing down all the open sockets listening on a Linux Mint 20 machine, you can follow any of the following three methods:

Method # 1: Listing all the Open Sockets Listening on a Linux Mint 20 Machine with the “ss” Utility:

If you want to list down all the open sockets listening on a Linux Mint 20 machine regardless of which Internet protocol they are using, then you need to execute the command shown below in your terminal:

$ ss –l

This command will list down all the open sockets that are listening on a Linux Mint 20 machine, as shown in the following image:

Method # 2: Listing all the Open TCP Sockets Listening on a Linux Mint 20 Machine:

If you want to list down all the open TCP sockets listening on a Linux Mint 20 machine, then you need to execute the command shown below in your terminal:

$ cat /proc/net/tcp

This command will list down all the open TCP sockets that are listening on a Linux Mint 20 machine, as shown in the following image:

Method # 3: Listing all the Open UDP Sockets Listening on a Linux Mint 20 Machine:

If you want to list down all the open UDP sockets listening on a Linux Mint 20 machine, then you need to execute the command shown below in your terminal:

$ cat /proc/net/udp

This command will list down all the open UDP sockets that are listening on a Linux Mint 20 machine, as shown in the following image:

Conclusion:

In this guide, we shared three different methods of listing down the open sockets listening on a Linux Mint 20 machine. The first method lists down all the open and listening sockets regardless of the Internet protocol they are following. The other two methods are specific to the TCP and UDP protocols.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.