FoundationLinux

How do you find a running process and stop it? What is the difference between SIGTERM and SIGKILL?

What they are really testing: Whether you handle processes gracefully or just reach for kill -9. The signal difference is the real test: do you understand graceful shutdown vs forced termination.

A real interview question

How do you find a running process and stop it? What is the difference between SIGTERM and SIGKILL?

What most people say

drag me

I would run kill -9 on the process id to stop it.

Jumping straight to -9 is the junior tell: it denies the process any cleanup and risks corruption. It also skips SIGTERM entirely, which is what you should try first.

The follow-ups they ask next

  • A process is stuck and even kill -9 does not remove it. Why?

    It is likely in uninterruptible sleep (state D), blocked in a kernel syscall, often on stuck I/O (a hung disk or NFS mount). The fix is the underlying I/O, not the signal.

  • How do you stop all processes by name at once?

    pkill <name> or killall <name>, but be careful with broad name matches; confirm with pgrep first.

What the interviewer is listening for

  • Tries SIGTERM before SIGKILL
  • Explains why -9 risks corruption
  • Knows ps/pgrep/top to find PIDs

What sinks the answer

  • Reaches for kill -9 first
  • Can't explain the signal difference
  • Unaware -9 skips cleanup

If you genuinely do not know

Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.

I find the PID with [ps aux | grep or pgrep], then send [SIGTERM via plain kill] so it [shuts down cleanly]. Only if it ignores that do I use [kill -9 / SIGKILL], which [forces it with no cleanup and risks corruption], so it is a last resort.

Keep going with linux

All 336 cloud engineer questions

Knowing the answer is not the same as recalling it under pressure

Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.

Start free