mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
translated
提交翻译
This commit is contained in:
parent
ddbb00d903
commit
7e587e142c
@ -1,145 +0,0 @@
|
||||
[#]: 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: "yzuowei"
|
||||
[#]: 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 don’t 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, let’s 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, let’s 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, let’s 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
|
||||
```
|
||||
|
||||
Let’s 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 can’t 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
|
@ -0,0 +1,146 @@
|
||||
[#]: 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: "yzuowei"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
如何在 Linux 中找到一个进程 ID 并杀死它 [CLI & GUI]
|
||||
======
|
||||
|
||||
**一个简单的教学展示教你如何找到正在运行中的进程 ID 并杀死它,你可以使用终端或着 GUI,这个方法适用于各类 Linux 发行版。**
|
||||
|
||||
你的 Linux 系统中运行的应用可能会让你的电脑变慢,特别是你的电脑配置较低的时候。在 Linux (以及所有其他 OS)中,程序或者应用都携带一个特别的 PID (进程 ID)可供你简单地分辨它们。
|
||||
|
||||
然而,作为初学者,大部分 Linux 用户并不知道如何在 Linux 中寻找运行中的进程并杀死它。在这篇指南中,我们将会解释不同的方法用以杀死 Linux 中的运行进程。这包括了使用终端和 GUI 的方法。
|
||||
|
||||
记住,你只应该杀死未响应的进程,或者你发现应用无法被正常关闭 (针对基于 GUI 的应用)。
|
||||
|
||||
### 如何在 Linux 中找到进程 id 并杀掉它们
|
||||
|
||||
在这一部分中,我们首先应该先学会如何找到运行进程的 PID,然后再学习用以杀掉它们的命令:
|
||||
|
||||
#### 找到正在运行中的进程
|
||||
|
||||
你可以使用命令 `top` 来列出所有正在进行中的进程和它们的 PID,以及其他细节。程序 top 在所有 Linux 发行版和所有基于 Unix 的系统中都是默认安装了的。
|
||||
|
||||
```
|
||||
top
|
||||
```
|
||||
|
||||
![Top program output][1]
|
||||
|
||||
同样地,你可以执行命令 `ps` 附带额外选项来获取某个指定的进程的 PID。例如,你可以使用以下命令来获得 `firefox` 的 PID。
|
||||
|
||||
```
|
||||
ps -el | grep -i firefox
|
||||
```
|
||||
|
||||
![Firefox process id using ps command - example][2]
|
||||
|
||||
现在你已经找到进程 id 了,让我们看看你该如何杀掉它。
|
||||
|
||||
#### 杀死运行中的进程
|
||||
|
||||
You can either use the process name or PID to kill the currently running process using the following commands:
|
||||
使用以下命令,你可以通过进程的名字或者 PID 来杀掉这个正在运行中的进程:
|
||||
|
||||
- **killall:** 通过运行进程的名字来杀死进程
|
||||
- **[kill][3]:** 通过 PID 来杀死进程
|
||||
|
||||
现在,让我们首先使用进程 `killall` 通过 Firefox 这个名字来杀死它的,命令如下:
|
||||
|
||||
```
|
||||
killall -9 firefox
|
||||
```
|
||||
|
||||
- 参数 `-9` 发送了信号 SIGKILL 通知 OS 来终止这个进程。
|
||||
- 使用以下命令,你也可以列出一些别的信号。
|
||||
|
||||
```
|
||||
kill -l
|
||||
```
|
||||
|
||||
同样地,如果你想要通过进程 ID 来杀死进程,你可以用以下命令:
|
||||
|
||||
```
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
在这个例子中,命令会长这样:
|
||||
|
||||
```
|
||||
kill -9 33665
|
||||
```
|
||||
|
||||
让我们看看在不同发行版中,你该如何使用图形用户界面 (GUI) 来杀死任意进程或应用。
|
||||
|
||||
### 通过 GUI 寻找进程 id 并杀掉
|
||||
|
||||
现在有很多图形界面程序可以枚列进程。大部分 Linux 发行版的桌面环境中已经携带了它们。我们在这里列举出了一些。
|
||||
|
||||
#### GNOME (在 Ubuntu, Fedora workstation 中,诸如此类) & 在 Linux Mint 中
|
||||
|
||||
在应用菜单中搜索 "system monitor" 并打开它 (译者注:中文桌面环境也可以搜 "system monitor",我在 ubuntu 里试过了)。在进程 (Processes) 标签页下找到你的进程,右击进程名字打开快捷菜单,选择选项“杀死” (Kill)。
|
||||
|
||||
![Kill a process in Linux using gnome system monitor][4]
|
||||
|
||||
#### KDE Plasma (Kubuntu,Fedora-KDE 或任何基于 Plasma 的发行版)
|
||||
|
||||
在应用菜单中搜索并启动 "system monitor"。这会打开以下程序。在左边菜单栏点击进程,你因该能看见一列正在运行的程序。你可以右击列表里的进程或应用并选择“杀死”来终止进程。
|
||||
|
||||
![System monitor in KDE Plasma][5]
|
||||
|
||||
#### Xfce 桌面
|
||||
|
||||
Xfce 桌面可以完成这项任务的原生应用是任务管理器 (Task Manager),你可以通过 `应用 (Application) > 系统 (System) > 任务管理器 (Task manager)` 来找到它。右击进程名字然后选择“杀死”来终止应用或进程。
|
||||
|
||||
![Xfce task manager to kill a process][6]
|
||||
|
||||
#### 如何在其他桌面或发行版上杀死一个进程或程序
|
||||
|
||||
如果你找不到任何相似的程序,你可以选择使用终端的方法。或者,你可以使用以下命令来安装 gnome-system-monitor。
|
||||
|
||||
**Ubuntu 以及相关发行版**
|
||||
|
||||
```
|
||||
sudo apt install gnome-system-monitor
|
||||
```
|
||||
|
||||
**Fedora 以及其相关的:**
|
||||
|
||||
```
|
||||
sudo dnf install gnome-system-monitor
|
||||
```
|
||||
|
||||
**还有 Arch Linux:**
|
||||
|
||||
```
|
||||
sudo pacman -S gnome-system-monitor
|
||||
```
|
||||
|
||||
### 总结一下
|
||||
|
||||
这就是你该如何在 Linux 中找到一个运行中的进程 id 并杀死它。我们已经解释了不同的方法:你可以通过名字或者 PID 来杀死进程。我希望这对你有所帮助。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/find-process-id-kill-linux/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[yzuowei](https://github.com/yzuowei)
|
||||
校对:[校对者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
|
Loading…
Reference in New Issue
Block a user