In this opportunity we will teach you How to check the ports in use in Linux. As soon as a port is open, network communication can be facilitated, but it can also expose your computer to outsiders.

Check open ports with NetCat

Netcat is a tool that can be found on most versions of Linux, it is quite easy to use and does not require another package to be installed for it to work. Before doing this check to find out if the port is open, you should know the two most interesting parameters in this application.

  • Z-parameter: This is a parameter in charge of closing a connection when the verification is finished. Otherwise, the program may run in a loop until you press control+C.
  • V-parameter: It is a parameter whose function is to verify that a port is open or closed.

If you are interested in knowing the status of a port, you should type the following command on your computer:

  • nc-zv {IP} {PORT}

If you want to check port 443, in your router you must type the following command:

  • nc-zv, If the port is opened you will see it as follows:

Is NetCat secure?

When you use this tool, it is normal to think that it can be used for improper purposes and yes, we are not going to lie to you about it. because hackers use these programs to break into other computers, dodging firewalls and in this way they can take control of them without anyone noticing.

What is recommended in these cases is that you download NetCat from a safe internet page. Similarly It is recommended to do all the analysis to see if it is necessary to install this program, Mastering this tool could bring many benefits and it will help us to know what the security threats are and deal with them more easily.

NetCat is a very good application, many use it to hack computers or operating systems, but if you are going to use it, we recommend that you do so with completely lawful intentions.

Check open ports with Nmap

This is the second method that we recommend for you to learn how to check the ports in use in Linux. It is an open source program, It is used to perform security audits and it has a design used for large networks, but if it is a single host it works quite well.

Nmap is the most chosen program for host discovery and also, it serves to know which are the ports that are open, this is a program that is not installed in Linux and therefore, you will have to download it from the internet or acquire it on your own.

The program works with raw IP packets, this with the intention of knowing which hosts are available, all the operating systems that are running at the moment together with their version, also which are the firewall filters that are being used and other similar characteristics.

Mostly those who administer networks and systems, use this program to carry out day-to-day tasks, which are the realization of the inventory, monitoring what activity a server or host is having in real time and also the administration of all the update programs. You can install it using this order:

  • sudo apt install nmap

As soon as it has been installed, you must place the command below to find out if you have any open ports:

  • nmap -p {PORT} {IP}

If a port is open you will see the following image:

Now, if a port is closed, or also protected by a firewall, the following image will appear:

By Manuel Garrido

Graduated in Computer Science, passionate about writing and technology. In Digital Guides I am going to offer you the best tutorials of the tools that I master the most, as well as recommendations of apps and programs that will surely interest you.