LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 268|回复: 0

write 对话

[复制链接]
发表于 2024-1-20 23:40:27 | 显示全部楼层 |阅读模式
与系统上在线用户进行谈话,通过 write 将信息传给接收者

write 使用者账户 [用户所在终端接口]


[root@study ~]# who
mrcode   pts/0        2020-02-25 22:28 (192.168.0.105)
mrcode   pts/1        2020-02-25 22:28 (192.168.0.105)
root     pts/4        2020-02-25 22:28 (192.168.0.105)
root     pts/5        2020-02-25 22:28 (192.168.0.105)
# 笔者使用的是 ssh 软件链接的。类似 xshell 软件,所以可能显示的不是 tty 接口把
# 开启了两个链接,并且使用 su 切换的账户,是通过这个 who 看不出来的
# 只会显示最初登录系统的账户信息
# 笔者这里开启了两个窗口,一个登录 mrcode 账户,一个登录 root 账户

[root@study ~]# write mrcode pts/0
Hello,there:
Please dont't do anything wrong...
# 在 root 窗口上,对 mrcode pts/0 的终端接口写信息
# 上面两行是 root 传递的文字信息
# 要结束传递的话,需要通过组合键 ctrl + d 结束


# 在 mrcode 这边就会看到传递过来的信息了
[mrcode@study ~]$
Message from root@study.centos.mrcode on pts/2 at 22:33 ...
Hello,there:
Please dont't do anything wrong...
EOF

这两个交互式这样的,当 root 敲入 write mrcode pts/0 指令时,mrcode 这边就相当于进入了一个聊天窗口,输入一行按下回车键,信息就会显示到对方那边去。所以他们两个就可以谈话了

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表