Current location - Quotes Website - Collection of slogans - How to test whether the linux port is open?
How to test whether the linux port is open?
1. The most common way to test whether a port is open is to use the telnet command. The specific usage method is as follows:

telnet localhost 80?

Command description: telnet is the command keyword, localhost is the IP address, this machine can be represented as localhost, and 80 is the port.

If a character like the following indicates that the port is open.

Trying 127.0.0. 1 ...

Connected to the local host.

The role of escape is']'

If a prompt similar to the following appears, the port is not open: the connection is denied.

2. Another way is to query the port number opened by this machine, taking ubuntu 14 as an example (note: if you execute the command as root, you will see more information):

netstat -anlp | grep -v unix

In the printed information, check the local address column: as shown below.

3.lsof command. You need to use the root account to execute this command to make it work better.

lsof -i :80

Explanation:

Lsof (List Open Files) is a tool to list the files opened by the current system. In the linux environment, everything exists in the form of files, through which you can access not only regular data, but also network connections and hardware.

Lsof -i command keyword. : 80 port view. Pay attention to the writing of colon.