用 pkill 按名称结束进程
使用 pkill 向所有名称匹配的进程发送终止信号,无需先查找 PID。
运行 pkill firefox,向所有 Firefox 进程发送 SIGTERM 请求其正常退出;需要强杀时改用 pkill -KILL firefox。
01命令
命令
$ pkill firefox02作用说明
pkill 会遍历进程表,向名称匹配的每个进程发送信号,默认信号是 SIGTERM,即请求进程正常退出。信号也可以显式指定:pkill -TERM firefox 是温和方式,而 pkill -KILL firefox(即 pkill -9 firefox)发送无法被捕获或忽略的 SIGKILL 强制结束进程。还可以用 -u <用户名> 只匹配某个用户的进程。
03风险
!注意: pkill 会结束你用户下所有匹配的进程,包括并不想停掉的进程——先运行 pgrep -a <名称> 预览将会被杀掉的进程再操作。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- pgrep, pkill, pidwait - look up, signal, or wait for processes based on name and other attributes依据: "pkill ... will send the default signal (SIGTERM) to each process instead of listing them on stdout." The page also documents the -signal and -l/--list-signals options.
- Ubuntu Manpage: pgrep, pkill, pidwait - look up, signal, or wait for processes依据: "pkill ... will send the default signal (SIGTERM) to each process instead of listing them on stdout."
最后验证: 2026-09-19 · 分类: 系统与设置