关闭某个登录用户

[root@localhost ~]# w

 20:26:02 up  3:13,  3 users,  load average: 0.00, 0.00, 0.00

USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT

root     tty1     -                17:14    3:08m  0.07s  0.07s -bash

root     pts/0    192.168.18.20    20:16    2:35   0.44s  0.40s /usr/bin/python /usr/bin/yum install dhcp

root     pts/1    192.168.18.20    20:25    0.00s  0.03s  0.01s w


pts/0终端的任务卡死、若要结束该任务、先获取该终端的PID

[root@localhost ~]# ps -ef|grep pts/0

root      4313  3399  0 20:16 ?        00:00:00 sshd: root@pts/0 

root      4315  4313  0 20:16 pts/0    00:00:00 -bash

root      4362  4315  0 20:23 pts/0    00:00:00 /usr/bin/python /usr/bin/yum install dhcp

root      4426  4368  0 20:29 pts/1    00:00:00 grep pts/0

kill 4362即可结束该任务


关闭某个登录的用户

[root@localhost ~]# echo "i will close you" > /dev/pts/0   (该用户会收到消息)

[root@localhost ~]# fuser -k /dev/pts/0

/dev/pts/0:           4315


你可能感兴趣的:(linux,关闭,登录用户)