Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

How to kill all process of one user?

When I make ps aux I obtain a list of process with several users, and I want to kill all process of user name1 for example! What's a command to do that in Ubuntu?

share|improve this question
possible duplicate of How do I kill all a user's processes using their UID – Gilles Mar 27 '12 at 21:44
If the users are real persons this probably isn't a good idea. I also think you want to kill processes to save time. This is a very bad idea. For instance, the services in Ubuntu can be stopped using sudo service the-service-name stop. Killing processes may left corrupted files, databases, etc. – tiktak Mar 28 '12 at 15:39

In this case, it's pretty simple, you can use killall to kill, or send any other signal, to a bunch of processes at once. One of the "filtering" options is the owner: killall --user name1

share|improve this answer
I wasn't aware of the --user argument, thanks! – jmtd Mar 27 '12 at 14:32
It should be noted that killall in e.g Solaris Unix kills all running processes it can! See: en.wikipedia.org/wiki/Killall – donothingsuccessfully Mar 27 '12 at 18:25

Adding another option because nobody has mentioned it, and I don't like killall (using it on solaris can cause disaster).

pkill is more portable

pkill -u username
share|improve this answer

Identify the user, then killall -user <username>

They will have a bash (or similar) process associated with their login session killing that will kill their session.

To get a potentially better overview of what a user is doing - try pstree <username>

Hope this helps, Dave

share|improve this answer
you need two dashes before user e.g. --user – jmtd Mar 28 '12 at 10:40

Install slay:

aptitude install slay

Then issue slay some-user.

Be aware that if you kill off stuff for users you don't know the purpose for, you may render your machine unusable (until you restart).

If you really don't want to install slay:

ps -e -o user,pid | grep '^some-user ' | awk '{ print $2 }' | xargs kill

(wait a bit)

ps -e -o user,pid | grep '^some-user ' | awk '{ print $2 }' | xargs kill -9
share|improve this answer
Btw awk can grep something itself. No need to do grep smth | awk, cause you can use just awk '/smth/{...}' instead. – rush Mar 27 '12 at 14:36

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.