Progress: 0/62 (0%)

❌ Killing or Stopping Processes

Killing or Stopping Processes

Sometimes, a process misbehavesβ€”like freezing your program or eating too much CPU. Linux gives you tools to stop or kill it safely.
Think of this like asking someone in the office to stop working or forcefully removing them if they won't stop.

2a. kill Command

What it does: Sends a signal to a process to stop it.

Analogy: You politely ask an employee (process) to stop their task.

kill 1234

1234 is the PID of the process.

Common signals:

  • -15 β†’ SIGTERM (default, polite stop)
  • -9 β†’ SIGKILL (forceful, immediate stop)

Use -9 only if polite stop doesn't work.

2b. pkill Command

What it does: Kill a process by name, not PID.

Analogy: You tell all employees named "Alice" to stop working.

pkill firefox

Stops all Firefox processes.

Tip: Use pkill -u username processname to kill a user's specific process.

2c. killall Command

What it does: Similar to pkill, kills all processes with a specific name.

Analogy: You send an office-wide memo: "Everyone running Firefox, stop immediately!"

killall firefox

Difference from pkill:

  • pkill can be more flexible with patterns
  • killall strictly kills all exact process names

Real-life analogy

βœ… Key takeaway:
kill β†’ kill by PID
pkill β†’ kill by process name, flexible
killall β†’ kill all exact matches of a process name

I'll pause here.
Do you understand Killing or Stopping Processes, or want me to give a quick real-life mini-scenario for it?