I can't seem to find any examples on the internet for this particular task.

  • Try for i in $(pgrep -U $UID); do kill -9 $i; done or pkill -U $UID whichever seems suitable, replace $UID with the required UID or just assign it a value beforehand. – Kunal Gupta May 27 '18 at 8:06
  • All solutions will require CAP_KILL (permission to kill any process), or to be root (root has this permission). – ctrl-alt-delor May 27 '18 at 11:36

You can do this either via:

for i in $(pgrep -U $UID_OF_ANOTHER_USER); do kill -9 $i; done



You can use the first one to do something more other than just killing those processes, like listing all of them while killing.

  • 1
    As $UID is the user id of the current user. This will kill your own processes. In addition, it may kill itself before finishing. – ctrl-alt-delor May 27 '18 at 11:34

Here is a simple solution, that will work if you are root.

su $uid -c kill SIGSTOP -1

Explanation: become that user, and kill everything that you can.

All solutions will require CAP_KILL (permission to kill any process), or to be traditional root (root has this permission), and permission (capability to change its own uid), as used by this solution.

Note I sent sigstop, this will pause the process (as asked for ☺). Chose the signal that you want. Use sigkill as last resort.

killall -u $user -STOP

This is safe if run as another user and (for other signals) if no parent process belongs to the affected user.

ctrl-alt-delor's solution is probably better (safer). This one has the advantage of giving you a real exit code, though. The other one probably does not as both su and kill get killed themselves.

Not the answer you're looking for? Browse other questions tagged or ask your own question.