How to view port usage and kill process under CentOS (Linux)

Source: Internet
Author: User

Use this command: NETSTAT-NAP

[Email protected] sphinx]# Netstat-nap

Active Internet connections (servers and established)

Proto recv-q send-q Local address Foreign address State Pid/program Name

Kill process

To end a process with the KILL command: Kill XXX
Freq used: kill-9 324
Linux also provides a killall command that directly uses the name of the process rather than the process identification number, for example: # killall-9 Name

kill-9 xxx

is to force the end process

Killall is still more practical.

CentOS can be viewed with netstat or lsof, under Windows can also be viewed with netstat, but the parameters will be different

Linux:

Netstat-nap #会列出所有正在使用的端口及关联的进程/Application
Lsof-i:p ortnumber #portnumber要用具体的端口号代替, you can list this port directly listen to the process/application

One, check which process the port is taking up

The code is as follows Copy Code

Netstat-lnp|grep #88请换为你的apache需要的端口, such as: 80

SSH executes the above command to see which process is being used by Port 88. For example, the process number is 1777.

Second, view the details of the process

PS 1777

SSH executes the above command. View the program detail path for the corresponding process number. Such as.

Third, kill the process, restart Apache

The code is as follows Copy Code
Kill-9 1777 #杀掉编号为1777的进程 (Please enter according to the actual situation)
Service httpd Start #启动apache


SSH executes the above command, and if there is no problem, Apache will be able to start normally.

Windows system:

Netstat-nao #会列出端口关联的的进程号, which task can be viewed by Task Manager

The last column of the program PID, and then through the tasklist command: tasklist | Findstr 2724

And then end this program with mission management.

How to view port usage and kill process under CentOS (Linux)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.