Linux Mint

How to Check if a Port is Open on Linux Mint 21

Several reasons might occur when you need to know about ports in the system. It could be when you are facing network issues or having security problems while using the Linux operating system. Besides such issues, if you want to upgrade the security level of your machine, you should know about opened port details.

There are different types of ports in a system i-e Transmission Control Protocol (TCP) and User Datagram Protocol (UDP).

TCP is the most used protocol on the internet while UDP is a replacement for it if you don’t need to look for error-related issues while transmitting data.

How to Check if a Port is Open on Linux Mint 21

In Linux distributions, we have several command-line tools introduced by the Linux system to display open ports on the terminal. Some of the most used and easy utilities are listed below:

  1. netstat Command-line Utility
  2. ss Command-line Utility
  3. lsof Command-line Utility
  4. nmap Command-line Utility

1: Checking a Port using netstat Command-line Utility

The netstat is the most powerful and popular command-line tool among Linux users to monitor networks. Let’s use this command to display all open ports including TCP and UDP on terminal:

$ sudo netstat -tulpn

In the above command:

t: used for TCP ports
u: used for UDP ports
l: used for listening server sockets
p: used for PIDs and
n: used for not to display names

2: Checking a Port using ss Command-line Utility

The ss command-line tool is another way to find open ports in Linux systems as it provides more information about the network than netstat command tool. To display open ports with the help of this command, run in terminal:

$ sudo ss -tulpn

3: Checking a Port using lsof Command-line Utility

As the name describes List Open Files (lsof) helps to display the open files in the system. We can also use this command-line tool to show open ports in the terminal, so type to get the required output:

$ sudo lsof -i -P -n | grep LISTEN

The grep Listen command will help to display all open ports.

4: Checking a Port using nmap Command-line Utility

The nmap command-line tool is used for network auditing and exploration but is also helpful to detect open ports. It is not the built-in command in Linux distributions, so before making use of it, we need to get it on the system, type the mentioned installation command:

$ sudo apt install nmap

As it is downloaded to our Linux Mint system; now run the following command to display all TCP port connections on the terminal with the help of nmap command tool:

$ sudo nmap -sT -O localhost

To display all UDP port connections on the system, type in terminal:

$ sudo nmap -sU localhost

Conclusion

Letting know about your open port connections is necessary when you find troubleshooting and security issues in the network. Or in another case, if you want to upgrade the security level of your machine, you should know about open ports details.

This article has mentioned all the easy and possible ways to display open ports on Linux Mint 21 system. We have used the popular command-line tools for this purpose i-e, nmap command-line tool, netstat command-line tool, ss command-line tool, and lsof command-line tool.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.