有没有让我发送消息给其他login用户的命令? 我想例如在关机或重新启动服务器之前通知用户。
允许您向其他用户发送消息的最老的命令之一称为write 。
为了使用户能够使用写入来获取消息,您必须启用它(以root身份)。
只运行mesg会显示你是否启用。 mesg y启用它。 mesg n将其禁用。
然后,发送消息:运行who查看当前login到计算机的用户列表,在第二列中,您将find他们的tty编号:
[root@centolel ~]# who root pts/1 2017-03-15 19:22 (10.13.0.2) lel pts/4 2017-03-15 19:30 (10.13.0.2)
然后运行:
write [user] [tty]
它会让你直接发送消息到用户的terminal。
例:
write lel /dev/pts/4
然后开始input你的信息。
wall是另一种select,并使用如下:
sudo wall 'rebooting in 5 minutes'
从手册页:
NAME wall - write a message to all users SYNOPSIS wall [-n] [-t timeout] [message | file] DESCRIPTION wall displays a message, or the contents of a file, or otherwise its standard input, on the terminals of all currently logged in users.