Finding & Killing Processes by Name (pgrep, pkill, killall)
Concept & Overview
In fast-paced system operations, looking up process IDs with ps aux | grep name just to pass a numerical PID into kill is slow and error-prone. Linux provides process lookup and signal tools that operate directly by process name:
- pgrep : Scans active processes and returns matching PIDs. Adding -a outputs the full command line alongside the PID.
- pkill : Sends termination signals directly to all processes matching the pattern (e.g. pkill -9 miner).
- killall : Kills processes matching the exact binary executable name.
pgrep -a nginx, then terminate the unauthorized crypto-miner process with pkill -9 miner (or killall miner).Command Syntax Reference
| Command / Syntax | Description |
|---|---|
pgrep -a nginx | Find process IDs and full command lines matching nginx |
pkill -9 miner | Forcefully kill all processes matching miner |
killall miner | Kill all processes with the exact name miner |
Verification Objectives
These conditions will be automatically verified when you run commands inside the interactive terminal simulator:
- ○Search for nginx processes with pgrep -a nginx
- ○Kill rogue miner process with pkill -9 miner or killall miner
Ready to complete Quest 67?
Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.