从 Linux 终端终止进程的 3 种办法

注:机翻,未校。


How to Kill Processes From the Linux Terminal

Key Takeaways

  • Killing a process simply means forcing it to quit, and it can be necessary when a process is unresponsive or misbehaving.
    终止进程仅意味着强制其退出,当进程无响应或行为不端时,这可能是必要的。
  • Linux and macOS have commands like kill, pkill, and killall that allow you to terminate processes by either their PID or name.
    Linux 和 macOS 具有 kill、pkill 和 killall 等命令,允许您通过进程的 PID 或名称终止进程。
  • It’s important to be cautious when killing processes and ensure that you are terminating the correct one to avoid any unintended consequences.
    在终止进程时要谨慎,并确保终止正确的进程以避免任何意外后果,这一点很重要。

Killing a process is sometimes the only way to get rid of it. Despite the harsh name, “killing” a process just means “forcing it to quit.” Here’s how to do it from the Linux or macOS command line.
杀死一个进程有时是摆脱它的唯一方法。尽管这个名字很刺耳,但“杀死”一个进程只是意味着“强迫它退出”。以下是从 Linux 或 macOS 命令行执行此操作的方法。

What is a Process?

Running programs like your web browser, background processes associated with your desktop environment, and Linux system services are all processes.
运行程序(如 Web 浏览器)、与桌面环境关联的后台进程以及 Linux 系统服务都是进程。

You can lump processes into two groups:
您可以将流程分为两组:

  • Foreground processes are ones that have been started or launched by a user. They may be in a terminal window, or they may be a graphical application.
    前台进程是由用户启动或启动的进程。它们可能位于终端窗口中,也可能是图形应用程序。
  • Background processes are all of the processes that are started automatically and don’t have any interaction with users. They don’t expect input from users nor do they present results or output to them. Background processes are things like services and daemons.
    后台进程是自动启动的所有进程,与用户没有任何交互。他们不期望用户输入,也不向他们展示结果或输出。后台进程类似于服务和守护进程。

If the foreground processes are the front of theater staff and the actors, the background processes are the backstage “behind the scenes” team.
如果说前台流程是剧院工作人员和演员的前台,那么后台流程就是后台的“幕后”团队。

When processes misbehave or malfunction, they can hog too much CPU time, consume your RAM, or enter a tight computational loop and become unresponsive. Graphical applications can refuse to respond to mouse clicks. Terminal applications might never return you to the command prompt.
当进程行为异常或出现故障时,它们可能会占用过多的 CPU 时间、消耗 RAM 或进入紧密的计算循环并变得无响应。图形应用程序可以拒绝响应鼠标单击。终端应用程序可能永远不会将您返回到命令提示符。

What Does Killing a Process Do?

“Killing” a process just means “forcing the process to quit.” This may be necessary if the process is refusing to respond.
“杀死”一个进程只是意味着“强迫进程退出”。如果进程拒绝响应,则可能需要这样做。

Linux provides the kill, pkill, and killall commands to allow you to do just that. These commands can be used with any type of process, graphical or command line, foreground or background.
Linux 提供了 killpkillkillall 命令来执行此操作。这些命令可以与任何类型的进程、图形或命令行、前台或后台一起使用。

1、The kill Command<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值