[root@Centos ~]# w
01:52:52 up 18 min, 3 users, load average: 0.00, 0.02, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 172.16.30.204 01:39 6:52 3.67s 3.43s /usr/bin/python
root pts/1 172.16.30.204 01:45 0.00s 0.20s 0.02s w
root pts/2 172.16.30.204 01:52 2.00s 0.08s 0.08s -bash
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 172.16.30.204 01:39 6:52 3.67s 3.43s /usr/bin/python
root pts/1 172.16.30.204 01:45 0.00s 0.20s 0.02s w
root pts/2 172.16.30.204 01:52 2.00s 0.08s 0.08s -bash
看到有兩個用戶已經連接在主機上了,
再使用who am i 來查看自己登陸的是那個終端,下面自己是pts/1
[root@Centos ~]# who am i
root pts/1 2008-05-07 01:45 (172.16.30.204)
root pts/1 2008-05-07 01:45 (172.16.30.204)
接下來使用pkill命令將想踢出去的用戶,踢出去
[root@Centos ~]# pkill -kill -t pts/2
再使用w查看當前的用戶,可以看到pts/2已經給乾掉了
[root@Centos ~]# w
01:53:28 up 19 min, 2 users, load average: 0.00, 0.02, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 172.16.30.204 01:39 7:28 3.68s 3.44s /usr/bin/python
root pts/1 172.16.30.204 01:45 0.00s 0.23s 0.01s w
[root@Centos ~]# w
01:53:28 up 19 min, 2 users, load average: 0.00, 0.02, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 172.16.30.204 01:39 7:28 3.68s 3.44s /usr/bin/python
root pts/1 172.16.30.204 01:45 0.00s 0.23s 0.01s w