Server Guide and Blog

Rock Your Linux

By

Force a UNIX or Linux User to Logout

If you have a zombie user logged into a server, or you want to force a user to logout use the “who” command. Type “w” or “who” in a command prompt to see which users are logged in, and then use the pkill command to force them out. pkill -KILL -u “username” Pop in a particular username and boot them out the door.

5 Responses to Force a UNIX or Linux User to Logout

  1. WARNING: by all means DON’T use this on Root cuz it kills -everything- running under Root’s name, requiring a reboot !

    At least on my Debian 6 Dedicated Machine I couldn’t connect by any means, so I had to use remote reboot.

  2. Killah says:

    I wish I would’ve read your comment earlier :D Of course just did
    pkill -KILL -u root
    and had to reboot the machine ;p

  3. Benoit says:

    “pkill -KILL -u username” sends the unforgiving KILL signal to all processes owned by that user. So, OK, it logs the user off, as a side effect, but it does a lot more! Use wisely. To just logoff someone, kill his shell process. Find it with “ps u username”.

  4. Jouni "rautamiekka" Järvinen says:

    Exactly, Benoit. That’s why it’s worst idea to use it on Root.

  5. Ahmad Hamada says:

    skill -KILL -t /dev/pts/*
    //Kill users on PTY devices.

    skill -STOP -u viro -u lm -u davem
    //Stop three users.

Leave a Reply