Linux Commands

Check Ports in Use in Linux

The ports in Linux are mostly used for networking when you wish to connect a host with a client. The ports should be in the listening state whenever they intend to accept the connection requests. In this article, we will learn the methods of listing down the ports that are in use or in other words, the ports that are in the listening mode in Linux.

Two Methods of Checking the Ports in Use in Linux

Below we have explained the two easiest and simplest methods of checking the ports in use in Linux. You will have to go through each of these methods to quickly learn them.

Method # 1: Usage of the Netstat Command

In this method, we will be using the Netstat command in Linux for checking the listening ports in the following manner:

$ sudo netstat –ltup

The above-mentioned command will list both the TCP and UDP ports that are currently in use on the terminal as shown in the image below:

Method # 2: Usage of the SS Command

Alternatively, you can use the SS command for listing the ports in use on the terminal in the following manner:

$ sudo ss –lntu

The listening ports of our Linux system are shown in the image below:

Conclusion

By picking out a method of your choice from the ones explained above, you can quickly find out the ports that are in use in Linux. In this way, if you are intending to close any unused port, you will easily be able to do that after knowing that it is still in the listening state.

Similar Posts