Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of checking Port occupancy by linux

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of linux to check the port occupation, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

How linux checks port occupancy: use [lsof-I port number or netstat-tunlp | grep port number] to see what process the port is occupied by.

How linux looks at port occupancy:

1. Common commands:

(1) lsof-I port number

(2) netstat-tunlp | grep port number

Both commands can see what processes the port is occupied by.

2. Lsof-I is used to display the process that meets the conditions. Lsof (list open files) is a tool that lists the files opened by the current system. Execute the lsof-I command as the root user, as shown below

The meaning of each column of the lsof output is:

COMMAND: the name of the process or how the process is started

PID: process id

USER: process owner

FD: file descriptor

TYPE: protocol type

DEVICE: Port number

SIZE/OFF: offset

NODE: protocol name

NAME: node name

3. Lsof-I: Port number, which is used to view the occupancy of a port, for example, to check the usage of port 22, lsof-i 22, as shown below

4. Netstat-tunlp is used to display the port and process of tcp,udp, as shown below.

In the command, the words "t _ () _ () u ~ () ~ (n) ~ (1) p have different meanings:"

-t displays only tcp-related

-u displays only those related to udp

-n unlimited time alias, which shows that all numbers are converted to numbers

-l displays only those in the Listen (listening) state

-p displays the name of the program that established these connections

5. Netstat-tunlp | grep port number, which is used to view the progress of the specified port number, such as netstat-tunlp for port 22, as shown in the figure below.

Thank you for reading this article carefully. I hope the article "linux ways to check Port occupancy" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report