How to check if a port is occupied in LINUX

PHPz
Release: 2023-05-25 15:28:06
forward
2262 people have browsed it

How to check whether a certain port is occupied in LINUX

1.netstat -anp |grep Port number

I take 3306 as an example, netstat -anp |grep 3306 (Note here, I am operating as a normal user, so I added sudo. If I am operating as a root user, I can view it without adding sudo)

How to check if a port is occupied in LINUX

In the figure, we mainly look at the monitoring status for the LISTEN table , which indicates that it has been occupied. The last column shows that it is occupied by the service mysqld. Check the specific port number. As long as there is a row like the picture, it means that it is occupied.

2.netstat -nultp (No need to add port number here)

This command is to view all currently used ports,

How to check if a port is occupied in LINUX

You can see from the picture that my port 82 is not occupied

3.netstat -anp |grep 82 Check the usage of port 82,

How to check if a port is occupied in LINUX

It can be seen that there is no LISTEN line , so it means that it is not occupied. Note here that the LISTENING shown 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 lines to indicate 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!

Related labels:
source:yisu.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template