How To Check If Port Is Open In Linux? – POFTUT

How To Check If Port Is Open In Linux?

I have some servers and I want to check which ports are open. Open ports give clue about the load and security about the system. Open ports mean there is services running on the server and clients are using these so a load of this system is generally higher than other servers. Open ports can be used by attackers. Also, open ports will prevent services to use the same port as Nginx and Apache.

Check Open Port With Lsof

We will use lsof which is a tool to list files, processes and their relevant ports. We will filter lines that contain LISTEN which is used by open ports.

  • -i will provide internet protocol related process
  • -P will prevent protocol names and use port numbers
  • -n will prevent hostnames and use IP addresses
Check Open Port With Lsof

Check Open Port With Lsof

Check Ports With Netstat

netstat is another useful tool which provides network related information about the host. Following command will check both TCP and UDP ports which are in listen mode or open.

Check Ports With Netstat

Check Ports With Netstat

Check Ports By Scanning With Nmap

Nmap is a security tool which is used by pentesters and hackers. Nmap is very useful so we can use it to find open ports. Nmap can be used to find open ports on localhost or remote host even on the internet. To get more information about nmap to look at our Nmap Tutorial.

Check Ports By Scanning With Nmap

Check Ports By Scanning With Nmap

LEARN MORE  How To Get Host Name and Domain Name Of Linux?

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)