How to check if a port is open in linux

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.

b9095e8f9fcb1cd9d57a6a1730253364.png

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

9b2ec8997efa590f3e7449b73c358808.png

2. Then in order to get higher privileges (view all ports), switch root user login here

739ac06f6dc82efcb72433256200301c.png

3. The first method is to use the lsof -i: port number command line, taking 80 as an example, as shown in the figure

14fe738a1f91802f9ce343eb9bf0293e.png

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.

4c933bce9bce82ad41a04629e57e9f5b.png

5. The second method is to use the netstat -aptn command line to view all open port numbers.

f26ffff32805c1975b8fe63ddc0fb7d4.png

6. The command as shown in the figure is to view all the port numbers using the udp protocol in the system

e0084ce01a6e0fbbb20762a5b51e976c.png

7. Then this command is to view the port number information using the tcp protocol in the system

5c9e28c24b206eab9518d35e5de34c04.png

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

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324123505&siteId=291194637