The method to check whether the port is open in linux: first open the port, switch the root user to log in; then use the [lsof -i:] port number command line; finally use the [netstat -aptn] command line to view all open port numbers.
The operating environment of this tutorial: linux7.3 system, DELL G3 computer
How to check if a port is open in linux:
1. First, we first open the Linux command interface to view the port, as shown in the figure
2. Then in order to get higher privileges (view all ports), switch root user login here
3. The first method is to use the lsof -i: port number command line, taking 80 as an example, as shown in the figure
4. If there is no output, it means that the port number is not enabled. For the convenience of testing, I will detect an open port number here, and the information as shown in the figure will be output.
5. The second method is to use the netstat -aptn command line to view all open port numbers.
6. The command as shown in the figure is to view all the port numbers using the udp protocol in the system
7. Then this command is to view the port number information using the tcp protocol in the system
8. Finally, there is a test method for the client, which is to use the Telnet ip port number command, but I did not test successfully in the virtual machine Linux, and the test in the remote Linux system was successful, I don’t know what happened