Friday, February 10, 2012

How to force users to logoff


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.

# w
 18:15:35 up 51 days, 20 min,  2 users,  load average: 0.00, 0.01, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
test     pts/0    :1.0             21Dec11 44days  0.03s  0.03s bash
root     pts/1    10.31.8.75       18:08    0.00s  0.19s  0.02s w

# pkill -KILL -u test
# w
 18:18:10 up 51 days, 23 min,  2 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/1    10.31.8.75       18:08    0.00s  0.20s  0.02s w