Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's say that I have several users running ''ruby'' processes simultaneously. How do I write a shell command to kill the ''ruby'' process of one particular user? (I'm on CentOS 5.5.)

share|improve this question
up vote 7 down vote accepted

pkill is good good for this:

pkill -u particularUser ruby

You can use pgrep with this as a test before you run it to see the process name and pid of what will be signaled:

pgrep -u particularUser -l ruby
share|improve this answer
Thanks, good answer. – Trevor Burnham Aug 17 '10 at 16:01

You can use the -u switch to killall to limit the scope to a single users. So for user abc you could do: killall -u abc /usr/bin/ruby (or whatever will match the ruby proccesses)

from man killall:

-u, --user
Kill only processes the specified user owns. Command names are optional.

share|improve this answer
Personally, I much prefer pkill over killall because (a) killall is evil on some Unixes other than Linux and (b) pkill has the pgrep alias that you can use to test that it's going to do the right thing. – freiheit Aug 16 '10 at 16:48

As a worst-case, if you can login or su - as the user, you can issue the famed kill -9 -1 command AS the user to clean up their processes.

Do NOT run as root :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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