In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to check port occupancy in Linux", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to check port occupancy in Linux" this article.
Linux check port occupancy method: 1, use lsof command, syntax format "lsof-I: port number"; 2, use netstat command, this command can display tcp, udp port and process and other related information, syntax format "netstat-tunlp | grep port number".
The operating environment of this tutorial: Red Hat Enterprise Linux 6.1 system, Dell G3 computer.
Linux can use the lsof and netstat commands to view port occupancy.
Lsof
Lsof (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
Example
View the occupancy of server port 8000:
# lsof-i:8000COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEnodejs 26993 root 10u IPv4 37999514 0t0 TCP *: 8000 (LISTEN)
You can see that port 8000 has been occupied by light nodejs services.
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: show processes using fd 4 lsof-I-U: show all open ports and UNIX domain files
Netstat
Netstat-tunlp is used to display relevant information such as the port and process of tcp,udp.
Netstat view the syntax format of port occupancy:
Netstat-tunlp | grep port number
-t (tcp) displays 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 8000tcp 00 0.0.0.0 grep 8000tcp 8000 0.0.0.015 * LISTEN 26993/nodejs
More commands:
Netstat-ntlp / / View all current tcp ports netstat-ntulp | grep 80 / / View the usage of all 80 ports netstat-ntulp | grep 3306 / / View the usage of all 3306 ports. These are all the contents of the article "how to check Port occupancy in Linux". 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.