Home >Operation and Maintenance >Linux Operation and Maintenance >How to check whether a port is occupied in Linux

How to check whether a port is occupied in Linux

青灯夜游
青灯夜游Original
2022-04-14 19:12:5618813browse

In Linux, you can use the netstat command to check whether the port is occupied. Method: 1. Log in to the system, right-click on a blank space on the desktop, and select "Open Terminal"; 2. In the terminal, execute the "netstat -anp | grep port number" command to view the output results. If "LISTEN" appears after the port, then Occupied.

How to check whether a port is occupied in Linux

The operating environment of this tutorial: CentOS 7 system, Dell G3 computer.

In Linux, you can use the netstat command to check whether the port is occupied.

Linux netstat command is used to display network status.

Using the netstat command allows you to know the network status of the entire Linux system.

Specific method:

1. Log in to the system, right-click on a blank space on the desktop and select "Open Terminal"

How to check whether a port is occupied in Linux

2. Terminal execution command: netstat -anp |grep port number

Take port 3306
as an example, execute the following command

netstat -anp |grep 3306

The usage of port 3306
will be displayed. When LISTEN appears behind the port, it means the port is occupied.

How to check whether a port is occupied in Linux

Extended knowledge:

If you want to view all currently used ports, you can use the following command:

netstat   -nultp

How to check whether a port is occupied in Linux

It can be seen from the picture that port 82 is not occupied.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to check whether a port is occupied in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn