1.首先查看当前账户
[hadoop@weekend01 ~]$ who
hadoop tty1 2016-11-14 09:31 (:0)
hadoop pts/0 2016-11-14 09:32 (:0.0)
hadoop pts/1 2016-11-14 09:35 (:0.0)
hadoop pts/2 2016-11-14 09:35 (:0.0)
hadoop pts/3 2016-11-14 09:35 (:0.0)
hadoop pts/4 2016-11-14 09:35 (:0.0)
hadoop pts/5 2016-11-14 09:35 (:0.0)
hadoop pts/6 2016-11-14 09:35 (:0.0)
查询每个用户最近登陆时间lastlog
Username Port From Latest
root pts/7 192.168.1.119 Wed Nov 9 12:57:40 +0800 2016
2.向所有用户广播一跳消息
[hadoop@weekend01 ~]$ wall "Hello,everyone I am sishen,what's your name?"
Broadcast message from hadoop@weekend01 (pts/0) (Mon Nov 14 10:01:59 2016):
Hello,everyone I am sishen,what's your name?
[hadoop@weekend01 ~]$
Broadcast message from hadoop@weekend01 (pts/0) (Mon Nov 14 10:01:59 2016):
Hello,everyone I am sishen,what's your name?
这样pts/0到pts/6都可以收到这条消息
3.向指定用户发送消息,使用write命令
[hadoop@weekend01 ~]$ who
hadoop tty1 2016-11-14 09:31 (:0)
hadoop pts/0 2016-11-14 09:32 (:0.0)
hadoop pts/1 2016-11-14 10:08 (:0.0)
hadoop pts/2 2016-11-14 10:08 (:0.0)
hadoop pts/3 2016-11-14 10:08 (:0.0)
hadoop pts/4 2016-11-14 10:08 (:0.0)
hadoop pts/5 2016-11-14 10:08 (:0.0)
hadoop pts/6 2016-11-14 10:08 (:0.0)
root pts/7 2016-11-14 10:08 (192.168.1.119)
root pts/8 2016-11-14 10:20 (192.168.1.119)
root pts/9 2016-11-14 10:19 (192.168.1.119)
root pts/10 2016-11-14 10:21 (weekend06)
[root@weekend06 ~]# ssh weekend01
[hadoop@weekend01 ~]$ write root pts/10
Hello,I am sishen,What's your name?
[root@weekend01 ~]#
Message from root@weekend01 (as hadoop) on pts/9 at 10:21 ...
Hello,I am sishen,What's your name?
使用Ctrl+d来结束对话
如果不想接收消息可以使用
[root@weekend01 ~]# mesg n来关闭,这样除了root之外的信息就不会接收了
也可以使用
[hadoop@weekend01 ~]$ who
hadoop tty1 2016-11-14 09:31 (:0)
hadoop pts/0 2016-11-14 09:32 (:0.0)
hadoop pts/1 2016-11-14 10:08 (:0.0)
hadoop pts/2 2016-11-14 10:08 (:0.0)
hadoop pts/3 2016-11-14 10:08 (:0.0)
hadoop pts/4 2016-11-14 10:08 (:0.0)
hadoop pts/5 2016-11-14 10:08 (:0.0)
hadoop pts/6 2016-11-14 10:08 (:0.0)
[hadoop@weekend01 ~]$ echo "hello ,what are you doing?" >/dev/pts/3
[hadoop@weekend04 ~]$ hello ,what are you doing?