通知并关闭指定的用户,ssh

查看当前系统的用户,who,w

1
2
3
4
5
6
$ w
15:05:42 up 4:49, 3 users, load average: 0.02, 0.01, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
server tty7 :0 14:06 4:43m 1:42 0.08s pam: gdm-passwo
server pts/0 :0.0 14:18 0.00s 0.23s 1.65s gnome-terminal
server pts/1 :0.0 14:47 4:43 0.01s 0.01s bash
1
2
3
$ who
bluebird tty1 2013-08-13 14:45 (:0)
bluebird pts/0 2013-08-13 14:45 (:0.0)

通知特定用户

通过设备文件通知,设备文件可以通过who命令看到

1
echo "I will close your connection" > /dev/pts/2

关闭用户连接

1
# fuser -k /dev/pts/2