How to check open ports in linux centos


To check open ports in CentOS Linux, you can use the following methods:

Using the netstat command:

Open a terminal or SSH into your CentOS machine and run the following command:

      codenetstat -tuln 

This will display a list of all listening ports on your system, along with the associated services and the corresponding process IDs (PIDs).

Using the ss command:

The ss command is another useful tool to display socket statistics. Open a terminal and run the following command:

  ss -tuln 

This will provide a similar output to netstat but with some additional information.

Using the nmap command:

If you have nmap installed, you can use it to scan for open ports on your CentOS system. Open a terminal and run the following command:

nmap localhost 

This will perform a port scan on the localhost (your own machine) and display the open ports along with their corresponding services.

Using the firewall-cmd command:

If you have firewalld (the default firewall management tool in CentOS) enabled, you can use the following command to list the open ports:

firewall-cmd --list-ports

This will show a list of ports that are open and allowed through the firewall.

These methods should help you identify the open ports on your CentOS Linux system. Remember to run the commands with appropriate privileges, such as using sudo if necessary.