In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
How to check the port occupancy under linux? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
In the process of using Linux, you need to know which ports are open by the current system, and to see the specific processes and users who open these ports, you can make a simple query through the netstat command.
The parameters of the netstat command are described as follows:
-t: indicate display TCP port-u: indicate display UDP port-l: display only listening sockets (the so-called socket is the program that enables the application to read, write, send and receive communication protocols (protocol) and data)-p: display process identifiers and program names, each socket / port belongs to a program. -n: show IP without DNS polling (operation can be accelerated)
All ports and process services on the current server can be displayed. Combined with grep, you can view a specific port and service.
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
Linux to check program port occupancy
Use the command:
Ps-aux | grep tomcat
It is found that there is no Tomcat process on port 8080.
Use the command:
Netstat-apn
View all processes and port usage. Find the following list of processes, the last column of which is PID/Program name
Port 8080 was found to be occupied by a Java process with a PID of 9658.
Further use the command: ps-aux | grep java, or directly: ps-aux | grep pid view
You can clearly know which program Port 8080 is occupied by! Then determine whether to use the KILL command to kill!
Method 2: use netstat-anp directly | grep portno
That is, netstat-anp | grep 8080
Netstat-anp | grep 8080-- > tcp 00 0.0.0.0 grep 8080 0.0.0.0 LISTEN 28500/javaps-aux | grep 28500-- > r/local/tomcat9-jforum/tomcat
You can also install lsof list open files//--- netstat-tunlp | grep port number netstat-anp | grep port number
Yum install lsoflsof-ilsof 8080 View 8080 Port Occupy lsof abc.txt display Open file abc.txt process lsof-c abc shows the file abc process now opens lsof-c-p 1234 lists the files opened by the process number 1234 lsof-g gid shows the process that belongs 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 using process lsof-I with fd 4 to display eligible processes lsof-I [46] [protocol] [@ hostname | hostaddr] [: service | port] 46-> IPv4 or IPv6 protocol-- > TCP or UDP hostname-- > Internet hostname hostaddr-- > IPv4 address service-- > service name (can be more than one) port-> port number (can be more than one) in / etc/service Lsof-I / / Show all open ports lsof-ilsof 80 / / Show all open port 80 processes lsof-I-U / / display all open ports and UNIX domain files thank you for reading! After reading the above, do you have a general idea of how to check port occupancy under linux? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are 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.