Here is a few methods for killing tasks for a specific user in Linux which may be required during account deletion or because somebody has managed to be an idiot and locked himself out with a fork bomb or some such.

The simple method is to use the utility called 'slay' which for Debian / Ubuntu and most other distributions is available if its not install you can install it using 'apt-get install slay'

It is very simple to use. Just running the command slay and it will kill all of that users processes.

The other method to use when slay is not available is a combination of ps and kill. You can use the following command

kill -TERM `ps h --User nobody -o pid`

Understanding the above can other advantages as well because you can switch out the --User for --Group and kill processes by group id as well as for a specific user.

Last Modified: 23 February 2017

Releated Posts

2013-03-01 - Linux - What and how to kill a zombie process
2013-02-14 - Linux - Getting sshfs to work
2012-12-12 - Linux - List / Copy group membership for users
2012-12-08 - Linux - ssh key authentication
2012-12-04 - Linux - sudo without a password
2012-10-13 - Rasberry Pi - Alternative method to play video without omx gstreamer element
2012-10-10 - How to run tcpdump as root
2012-07-13 - Linux - Killing all processes for a specific user
2012-04-05 - Using gdb to debug a core file
2012-01-16 - Linux - Color Coding The Bash Prompt
2012-01-14 - Linux - Automatically set the DISPLAY environment variable in SSH connection
2012-01-06 - Adding extra swap space to linux