Linux 用root踢掉已登录用户
首先使用w命令查看所有在线用户:
[root@VM_152_184_centos /]# w 20:50:14 up 9 days, 5:58, 3 users, load average: 0.21, 0.05, 0.02 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 101.45.224.253 20:48 0.00s 0.00s 0.00s w root pts/1 101.45.224.253 20:49 17.00s 0.00s 0.00s -bash hmj pts/2 101.45.224.253 20:50 2.00s 0.00s 0.00s -bash
执行命令:
pkill -kill -t TTY值
例:踢掉已登录用户hmj
pkill -kill -t pts/2
再用w命令查看是否已经强制踢掉:
[root@VM_152_184_centos /]# w 20:55:10 up 9 days, 6:03, 2 users, load average: 0.03, 0.03, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 101.45.224.253 20:48 0.00s 0.00s 0.00s w root pts/1 101.45.224.253 20:49 5:13 0.00s 0.00s -bash