Merge pull request #28151 from lkxed/20221207-0-How-to-Find-a-Process-ID-and-Kill-it-in-Linux--CLI---GUI-

[手动选题][tech]: 20221207.0 ️ How to Find a Process ID and Kill it in Linux [CLI & GUI].md
This commit is contained in:
Xingyu.Wang 2022-12-08 09:10:43 +08:00 committed by GitHub
commit e9a4ea2df8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,145 @@
[#]: subject: "How to Find a Process ID and Kill it in Linux [CLI & GUI]"
[#]: via: "https://www.debugpoint.com/find-process-id-kill-linux/"
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
How to Find a Process ID and Kill it in Linux [CLI & GUI]
======
**A simple tutorial demonstrates how to find a running process ID and kill it using the terminal and GUI method for various Linux distros.**
The running applications in your Linux system can slow down your system, especially if you have a low-end system. In Linux (plus all OS), programs or apps contain a specific PID (process ID) by which you can identify them easily.
However, as a beginner, many Linux users dont know how to find a running process in Linux and kill it. So in this guide, we will explain different approaches to kill the currently running processes in Linux. That includes the terminal and GUI methods.
Remember, you should only kill the process when it is not responding, or you are in a situation where the normal application closing is not working (for GUI-based apps).
### How to find process id and kill them in Linux
In this section, first, lets learn the method to find the PID of a running process and then commands to kill them:
#### Find the Currently Running Process
You can use the `top` command to list the currently running process with their PID and other details. The top program is installed by default in all Linux distros and all Unix-based systems.
```
top
```
![Top program output][1]
Similarly, you can run the `ps` command with additional options to get the PID of a specific process. For example, you can use the following command to get the PID of `firefox`:
```
ps -el | grep -i firefox
```
![Firefox process id using ps command - example][2]
Now that you have found the process id, lets see how you can kill it.
#### Kill the Running Process
You can either use the process name or PID to kill the currently running process using the following commands: 
- **killall:** Kill a process using the name of a running process
- **[kill][3]:** Kill the process with PID
Now, first, lets use the `killall` process to kill Firefox with its name, and here is the command:
```
killall -9 firefox
```
- The parameter `-9` sends the SIGKILL signal to the OS to terminate the process.
- You can also list down several other signals using the following command.
```
kill -l
```
Similarly, if you want to kill the process from the process ID, you can use the command given below: 
```
kill -9 <PID>
```
For this example, the command would be:
```
kill -9 33665
```
Lets see how you can kill any process or application using the graphical user interface (GUI) in various distros.
### Find process id to kill via GUI
There are many graphical programs available to list down processes. Most Linux distribution ships it as part of their desktop environment. Here are some of them.
#### GNOME (In Ubuntu, Fedora workstation, etc.) & in Linux Mint
Search for “system monitor” in the application menu and open it. On the processes tab, find your process. Right-click on the process name to bring up the context menu and choose the option kill.
![Kill a process in Linux using gnome system monitor][4]
#### KDE Plasma (Kubuntu, Fedora-KDE or any Plasma-based distro)
From the application menu, search and launch “system monitor”. This will launch the following program. From the left side, click on Processes, and you should see a list of programs running. You can right-click on the process/application and select Kill to terminate the process.
![System monitor in KDE Plasma][5]
#### Xfce desktop
The native application for this task on the Xfce desktop is Task Manager, which you can launch via `Application > System > Task manager`. Right-click on the process name and select kill to terminate the app or process.
![Xfce task manager to kill a process][6]
#### Other desktops or distros to kill a process pr program
If you cant find anything similar, you can choose the terminal method. Or, you can install the gnome-system-monitor using the following commands.
**For Ubuntu and related distros**
```
sudo apt install gnome-system-monitor
```
**In Fedora and related:**
```
sudo dnf install gnome-system-monitor
```
**And in Arch Linux:**
```
sudo pacman -S gnome-system-monitor
```
### Wrapping Up
So this is how you can find a running process id in Linux and kill it. We have explained different approaches that you can try to kill the process either from its name or PID. I hope this helps.
--------------------------------------------------------------------------------
via: https://www.debugpoint.com/find-process-id-kill-linux/
作者:[Arindam][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.debugpoint.com/author/admin1/
[b]: https://github.com/lkxed
[1]: https://www.debugpoint.com/wp-content/uploads/2022/12/Top-program-output.jpg
[2]: https://www.debugpoint.com/wp-content/uploads/2022/12/Firefox-process-id-using-ps-command-example.jpg
[3]: https://linux.die.net/man/1/kill
[4]: https://www.debugpoint.com/wp-content/uploads/2022/12/Kill-a-process-in-Linux-using-gnome-system-monitor.jpg
[5]: https://www.debugpoint.com/wp-content/uploads/2022/12/System-monitor-in-KDE-Plasma.jpg
[6]: https://www.debugpoint.com/wp-content/uploads/2022/12/Xfce-task-manager-to-kill-a-process.jpg