Debian 10: checking open ports

Ports are defined as communication endpoints that are required by two or more parties to communicate with each other over a network. Ideally, when two or more parties communicate with each other, their respective ports should remain open. However, sometimes, even when communication is interrupted, ports can remain open, which can cause various security problems. Moreover, unnecessarily open ports can also consume additional resources. Therefore, you must constantly check all open ports. Therefore, in this article, we will explain to you the various methods by which you can check open ports in Debian 10.

Methods for checking open ports in Debian 10:

To check open ports on Debian 10, you can use any of the four methods discussed in this article.

Method number 1:

To check open ports on Debian 10 using the netstat command, you need to follow these steps:

1. First of all, you need to start a terminal. To do this, click the Actions tab located on the desktop, type terminal in the search bar that appears, and then click the search result to launch a terminal in Debian 10.

2. Now enter the following command in your terminal and press the Enter key:

sudo apt-get install net-tools

Running this command will install the net-tools package, which is required to use the netstat command.

3. After executing this command, enter the following command in the terminal and press the Enter key:

netstat –pnltu

4. Once this command is successful, your screen will display a list of all the different ports with their states as shown in the following image:

Method number 2:

To check open ports in Debian 10 using the ss command, you need to follow these steps:

1. Start the terminal in the same way as described in the method above. Now enter the following command in your terminal and press the Enter key:

ss –lntup

2. After successful execution of this command, the screen will display a list of all the different ports with their states, as shown in the following image:

Debian 10: checking open ports

Method number 3:

To check open ports in Debian 10 using nmap command, you need to follow these steps:

1. Start the terminal in the same way as described in method # 1. Now enter the following command in your terminal and press the Enter key:

sudo apt-get install nmap

Running this command will install the nmap utility, after which we can successfully use the nmap command.

2. Now, if you want to check all open TCP ports, enter the following command in your terminal and press the Enter key:

sudo nmap –sT –O localhost

3. Once this command is successful, you can immediately see if any TCP ports are open, as shown in the image below:

Debian 10: checking open ports

4. However, if you want to check all open UDP ports, enter the following command in the terminal and press Enter:

sudo nmap –sU –O localhost

5. Once this command is successful, you can immediately find out if any UDP ports are open, as shown in the following image:

Debian 10: checking open ports

Method # 4:

To check open ports on Debian 10 using the lsof command, you need to follow these steps:

1. Start the terminal in the same way as described in method # 1. Now enter the following command in your terminal and press the Enter key:

sudo apt-get install lsof

Running this command will install the lsof utility, after which we can successfully use the lsof command.

2. Now enter the following command in your terminal and press the Enter key:

sudo lsof –i

3. Once this command is successful, your screen will display a list of all ports with their status, as shown in the image below:

Debian 10: checking open ports

Output:

Using any of the four methods discussed in this article, you can easily check all open ports in Debian 10. The only thing to note here is that commands followed by the sudo keyword require root privileges. Therefore, you must run them as they are.

Sidebar