1. Use thenetstat
command
netstat -anp |grep 端口号
as follows, taking 3306 as an example,netstat -anp |grep 3306
( Note here, the following is operated by an ordinary user, so sudo is added. If it is operated by the root user, you can view it without adding sudo), as shown in Figure 1:
LISTEN, which means it is occupied. The last column shows that it is occupied by the service mysqld. Check the specific port number.
netstat -nultp
netstat -anp |grep 82
LISTENINGshown in the picture does not mean that the port is occupied. Do not confuse it with LISTEN. When viewing the specific port, you must see the tcp, port number, and LISTEN. One line indicates that the port is occupied.
The above is the detailed content of How to check if a port is occupied in Linux. For more information, please follow other related articles on the PHP Chinese website!