Linux Labs

Users, permissions, and processes / Stage 12 of 13

Signals and process termination

Not running Starting usually ~20 s
Leave the lesson

Step 4 of 9 · theory · 4 min

Someone else's process

You stopped your own processes without trouble. A process of another account is a different story.

A process takes signals from its owner or from root. For someone else's process, kill prints Operation not permitted, whatever the signal, KILL included. Such a process is stopped with sudo kill.

Take the process number from pgrep -a or ps right before the signal and check the command line: PIDs are freed and handed to new processes, and a mistaken signal reaches the wrong one.

After the signal, check the result. If the process is gone, ps -p PID prints a single header line. If it is still alive, it is either finishing its work or not answering TERM.

Check yourself 1 question

An export running as www-data has to be stopped, but kill 2345 printed Operation not permitted. What do you do?

  • The running process does not stop because of that: the program is already in memory. To stop it, run sudo kill 2345.

  • In a new terminal you are still student, and the process still belongs to someone else. You need root: sudo kill 2345.

  • The refusal is about permissions: an ordinary user can send someone else's process no signal at all, and kill -9 prints the same.

A process takes signals from its owner or root, so someone else's process is stopped with sudo kill. You check the result with ps -p and the same PID.

Key points

  • Signals to someone else's process go through sudo kill; without sudo you get Operation not permitted.
  • Take the PID right before the signal and check the command line, then check the result in ps.
Ubuntu 24.04
Loading…