Linux > General Linux

Log Everyone Out Of The System

(1/1)

rohitj:
Log Everyone Out Of The System


If you want to log out all other users in a system, you can use pkill command.

who or w command - Show who is logged on and what they are doing.

pkill command - Kill user session and forcefully logout of the system.

For Example :

==========
root@vps [~]# w
root     pts/0    * 00:17    4:43m  0.04s  0.04s -bash
test     pts/4    *  05:04    3.00s  0.00s  0.00s -bash

root@vps [~]# pkill -KILL -u test
root@vps [~]# w
root     pts/0    * 00:17    4:45m  0.06s  0.06s -bash
==========

OR you can run below script.

who | awk '!/root/{ cmd="/sbin/pkill -KILL -u " $1; system(cmd)}'

Note : You have to run above script as root

Navigation

[0] Message Index

Go to full version