Linux: How to know if a logical port is being used?

Deepak Gupta May 28, 2022
Updated 2022/05/28 at 5:13 PM

GNU/Linux has fantastic built-in tools that are only known to those who frequently use the terminal. There are tools to assess connectivity, to do DNS tests, to analyze logs, etc.

If you want to see in the system a certain logical port is being used, know what you can do.

Each service in a system has one or more logical ports associated with it. This means that if a port is occupied by an application/service, it should not be used by another application or service. However, there are also tools, such as SSLH, that allow use the same communication port for SSL (HTTPS), SSH and even OpenVPN.

On a machine there are (theoretically) 65,536 logical TCP ports that can be used by the most diverse applications/services, which (theoretically) could have 65,536 different applications/services running simultaneously on our machine. Recalling what was mentioned in previous articles: the IP address identifies the machine it's the logical port identifies the application/service. In addition to the TCP ports we also have 65,536 UDP ports (theoretically).

netstat and lsof: The tools to know the usage of a logical port


One of the most used tools to know the connections established between our machine and others is the netstat. With this tool we can also know, in detail, which TCP and UDP communication ports are open on our machine, see the routing table, interface statistics, etc.

If you want to use netstat you can see this article which has several examples.

Linux: How to know if a logical port is being used?


The lsof or List of Open Files utility helps to list all open files on the system. We can use this tool to visualize all processes open on a specific logical port.

Linux: How to know if a logical port is being used?

And these are two of the most popular tools to know the status of logical ports in Linux. Before we end this article, here are 5 more suggestions for very interesting and powerful tools.

Share this Article
Leave a comment

Leave a Reply

Your email address will not be published.