Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

Sometimes when there are too many users logged in it can cause my computer to become very slow and laggy due to low amount of available RAM. I would like to be able to quickly log out the other users from the command line instead of manually switching into each user and logging them out.

Is this possible?

share|improve this question
up vote 19 down vote accepted

this is one answer

who -u

that give you the PID

Then you can kill the user session.

kill "pid"
share|improve this answer
This works but it has some strange side effects. – Alvin Row Nov 8 '10 at 23:16
@DoR ...which are..? – Oli Nov 8 '10 at 23:48
@Oli Such as GDM restarting, and trying to switch to a user that I killed not working. – Alvin Row Nov 8 '10 at 23:56

You may use who to check which users are logged in:


You can log-out the user by sending the KILL signal to the user-process with:

sudo pkill -KILL -u <username>

(which is same as sudo pkill -9 -u <username>)


sudo pkill -9 -u guest-2Rw4Lq

(to kill a guest session user named guest-2Rw4Lq)

share|improve this answer
This worked best for me. Simply running kill "pid" left a ton of processes by the user still running, where this killed them all. – thebaer Aug 30 '15 at 18:42

output who


sudo kill PID

PID is the four digit number at the end of the user readout

share|improve this answer
Please post textual information as text and not as images. You can easily copy & paste terminal content. – David Foerster Feb 11 at 9:12

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.