Saturday, November 15, 2008

kill user in the linux system - how to

below is the guide for centos5.1
i think this is a native command of Linux , should be applicable to any disto of Linux

check the user in the system with w or who: -
[root@www ~]# w
18:41:09 up 7 days, 52 min, 3 users, load average: 0.08, 0.09, 0.02
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/1 118.100.15.195 16:44 1:49m 0.01s 0.01s -bash
root pts/2 118.100.15.195 18:03 20:14 0.05s 0.05s -bash
alex pts/3 118.100.15.195 18:40 0.00s 0.02s 0.01s sshd: alex [pri

see, total is 3 users, as myself is alex, so i would like to kill user root for both session pts1 and pts2

So, this is the killing command, to kill the pts1 just do as the command like below: -
[root@www ~]# skill -KILL -v pts/1
pts/1 root 25170 bash

Now, i kill the pts2 sesssion: -
[root@www ~]# skill -KILL -v pts/2
pts/2 root 26041 bash

Check and ensure whether the user has been killed or not:-
[root@www ~]# w
18:41:31 up 7 days, 52 min, 1 user, load average: 0.06, 0.08, 0.02
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
alex pts/3 118.100.15.195 18:40 0.00s 0.02s 0.01s sshd: alex [pri

yes, the user no more exists in the system :P

No comments: