pkill — Kill processes by name (or attribute) without looking up the PID across all 5 shells
Equivalents in every shell
pkill firefoxFrom 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.
pkill firefoxSame 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.
pkill firefoxSame 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 &`.
Stop-Process -Name firefoxWildcards 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 }`.
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
pkill -9 firefoxStop-Process -Name firefox -Forcetaskkill /IM firefox.exe /FKill by full command-line pattern (not just name)
pkill -f "python myapp.py"Get-CimInstance Win32_Process -Filter "CommandLine LIKE '%myapp.py%'" | ForEach-Object { Stop-Process -Id $_.ProcessId -Force }Kill all of a specific user's processes
sudo pkill -u aliceGet-Process -IncludeUserName | Where-Object UserName -eq "DOMAIN\alice" | Stop-Process -ForceGotchas
- 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.