Skip to content
shellmap

pkillKill processes by name (or attribute) without looking up the PID across all 5 shells

Equivalents in every shell

Bashunix
pkill firefox

From the `procps` (Linux) / `pkill` (macOS) toolset. Matches `firefox` against the process NAME (truncated at 15 chars on Linux unless `-f` is passed). `-9` sends SIGKILL; `-f` matches the FULL command line (so `pkill -f node` kills every `node` process including npm scripts); `-u alice` restricts to alice's processes.

Zshunix
pkill firefox

Same external binary. macOS ships its own BSD `pkill` (slightly different flag set — `-l` is not supported, `-G` for primary group instead of `-g`). For portable scripts, stick to `-f`, `-u`, `-x` (exact match), and explicit signals.

Fishunix
pkill firefox

Same external. Fish does not modify argument quoting — `pkill -f "node app.js"` still matches the full quoted string against the process command line. Exit code 1 means no processes matched (vs 0 for "killed at least one") — useful for idempotent restart scripts: `pkill -f myapp; sleep 1; ./myapp &`.

PowerShellwindows
Stop-Process -Name firefox

Wildcards supported: `Stop-Process -Name "fire*"`. `-Force` skips the confirmation prompt for protected processes. By PID: `Stop-Process -Id 1234`. For a name-pattern match on the full command line, use `Get-CimInstance Win32_Process -Filter "CommandLine LIKE '%node%'" | ForEach-Object { Stop-Process -Id $_.ProcessId }`.

cmd.exewindows
taskkill /IM firefox.exe /F

`/IM <imagename.exe>` matches by image name (the `.exe` is required); `/F` forces termination (skip the WM_CLOSE message). `/T` kills the entire process TREE — useful for processes that spawn detached children. By PID: `taskkill /PID 1234 /F`. Filtering: `taskkill /FI "WINDOWTITLE eq My App" /F`.

Worked examples

Kill every process matching a name

Bash
pkill -9 firefox
PowerShell
Stop-Process -Name firefox -Force
cmd.exe
taskkill /IM firefox.exe /F

Kill by full command-line pattern (not just name)

Bash
pkill -f "python myapp.py"
PowerShell
Get-CimInstance Win32_Process -Filter "CommandLine LIKE '%myapp.py%'" | ForEach-Object { Stop-Process -Id $_.ProcessId -Force }

Kill all of a specific user's processes

Bash
sudo pkill -u alice
PowerShell
Get-Process -IncludeUserName | Where-Object UserName -eq "DOMAIN\alice" | Stop-Process -Force

Gotchas

  • Linux `pkill firefox` matches against the COMM field, which is truncated to 15 characters by the kernel. `pkill chromium-browser` matches NOTHING because the kernel stores only `chromium-browse` (15 chars). Pass `-f` to match the full command line, or use `-x chromium-browse` to match the truncated form exactly.
  • Without `-x` (exact match), `pkill node` ALSO matches `nodes`, `nodemon`, `node-red`, etc. `pkill -x node` matches only processes whose COMM is literally "node". For full-cmdline matching `pkill -f -x` requires an exact regex match against the entire `/proc/<pid>/cmdline`.
  • PowerShell `Stop-Process -Name firefox` matches all `firefox`-named processes — including any child renderer / GPU subprocesses (each shows up as `firefox` in `Get-Process`). Browsers commonly have 5–30 processes. To kill ONLY the parent: `Get-Process firefox | Where-Object { $_.Parent.ProcessName -ne "firefox" } | Stop-Process` (requires PowerShell 6+ for `.Parent`).
  • `taskkill /F` is NOT polite — it bypasses any WM_CLOSE handler the app uses to save state. For graceful shutdown on Windows, OMIT `/F`: `taskkill /IM firefox.exe` sends a close message that respects the app's save-on-exit flow. Use `/F` only when the app is hung.
  • On macOS, `pkill` and the Activity-Monitor "Force Quit" differ subtly: `pkill -9` is SIGKILL, but a sandboxed Mac App Store app that has been suspended by the OS may take 5–10 seconds to actually terminate because the kernel must first wake it. `kill -9 <pid>` exhibits the same behavior — there is no faster path.

WSL & PowerShell Core notes

pwshOn Linux/macOS pwsh, `Stop-Process` works against the unix process model — `-Name foo` matches against the process name from `/proc/<pid>/comm` (Linux) or BSD process table. The `-IncludeUserName` flag works on all platforms since pwsh 6. There is no `Stop-Process` equivalent of `pkill -f` (full-cmdline match) — shell out to `& pkill -f pattern` or filter via `Get-Process | Where-Object { (Get-Content /proc/$($_.Id)/cmdline -ErrorAction SilentlyContinue) -match "pattern" }` on Linux.
WSLInside WSL `pkill` kills only Linux-side processes. To kill a Windows process from WSL: `taskkill.exe /IM notepad.exe /F` (the .exe extension is required when invoking Windows binaries from WSL). From Windows-side pwsh: `wsl pkill firefox` runs `pkill` inside the default WSL distro. Note that `wsl --shutdown` (from Windows) sends SIGTERM to ALL WSL processes — the heavy-handed equivalent of `pkill -9 -u $(whoami)` across every distro.

Common tasks using pkill

Related commands