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

What are the port occupancy commands for the Linux system

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This "Linux system view port occupation command which" article, the article example code is very detailed, with a certain reference value, interested friends must refer to, for the "Linux system view port occupation command which", Xiaobian sorted out the following knowledge points, please follow the pace of the editor step by step slowly understand, then let us enter the topic.

Lsoflsof (list open files) is a tool that lists files currently open by the system.

Lsof view the syntax format of port occupancy:

Lsof-I: Port number instance to view the occupancy of server port 8000:

# lsof-iroot 8000 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nodejs 26993 root 10u IPv4 37999514 0t0 TCP *: 8000 (LISTEN) you can see that port 8000 has been occupied by light nodejs service.

Lsof-I requires the permission of the root user to execute, as shown below:

More lsof commands are as follows:

Lsof-ilsof 8080: view port 8080 occupied lsof abc.txt: show the process that opens the file abc.txt lsof-c abc: show the files opened by the abc process now lsof-c-p 1234: list the files opened by the process number 1234 lsof-g gid: show the process belonging to gid lsof + d / usr/local/: shows the files opened by the process lsof + D / usr/local/: in the directory as above, but will search the directory in the directory Longer lsof-d 4: display the process using fd 4 lsof-I-U: show all open ports and the UNIX domain file netstatnetstat-tunlp used to display tcp,udp ports and processes and other related information.

Netstat view the syntax format of port occupancy:

Netstat-tunlp | grep port number-t (tcp) shows only tcp related options

-u (udp) shows only udp related options

-n refuses to display aliases and can show that all numbers are converted to numbers

-l lists only the service status in Listen (snooping)

-p displays the name of the program that established the relevant link

For example, to view port 8000, use the following command:

# netstat-tunlp | grep 8000 tcp 00 0.0.0.0 grep 8000 0.0.0.0 LISTEN 26993/nodejs more commands:

Netstat-ntlp / / View all current tcp ports netstat-ntulp | grep 80 / / View the usage of all port 80 netstat-ntulp | grep 3306 / / check the usage of all 3306 ports kill after checking the process occupied by the port, if you want to kill the corresponding process, you can use the kill command:

For the example of kill-9 PID, we see that the PID for port 8000 is 26993. Use the following command to kill the process:

What are the versions of kill-9 26993Linux? the versions of Linux are Deepin, UbuntuKylin, Manjaro, LinuxMint, Ubuntu and so on. Among them, Deepin is one of the best-developed Linux distributions in China; UbuntuKylin is a derivative release based on Ubuntu; Manjaro is a Linux release based on Arch; LinuxMint's default Cinnamon desktop is similar to Windows XP's easy-to-use; Ubuntu is the Linux operating system based on desktop applications.

The above is all the contents of the article "what are the port occupancy commands in the Linux system?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report