Merge pull request #17811 from linusboyle/trans001

20200306 Communicating with other users on the Linux command line
This commit is contained in:
Xingyu.Wang
2020-03-21 07:29:22 +08:00
committed by GitHub
2 changed files with 146 additions and 148 deletions

View File

@@ -1,148 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (linusboyle)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Communicating with other users on the Linux command line)
[#]: via: (https://www.networkworld.com/article/3530343/communicating-with-other-users-on-the-linux-command-line.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
Communicating with other users on the Linux command line
======
Thinkstock / Linux
Sending messages to other users on the Linux command line can be very easy, but there are a number of commands that you might want to consider. In this post, well look at four commands and see how each of them works.
### wall
The **wall** command (as in "write all") allows you to send a message to all users who are currently logged into the system. This implies that the system is likely a server and that users are working on the command line. While the wall command is generally used by sysadmins to send out notices to users to let send out information (e.g., that the server is going down for maintenance), it can be used by any user.
A sysadmin might send out a message like this:
```
$ wall The system will be going down in 15 minutes to address a serious problem
```
Everyone logged into the system will see something like this:
```
Broadcast message from admin@dragonfly (pts/0) (Thu Mar 5 08:56:42 2020):
The system is going down in 15 minutes to address a serious problem
```
If you want to use single quote marks in your message, enclose the message in double quote marks like this:
```
$ wall “Dont forget to save your work before logging off”
```
The outside quote marks will not show up in the transmitted message, but, without them, the command sits and waits for a closing single quote.
### mesg
If, for some reason, you dont want to accept messages from another user, you can stop them from arriving with the **mesg** command. This command can be used with a “n” argument to refuse mail from the user or a “y” argument to allow the messages to arrive.
[][1]
```
$ mesg n doug
$ mesg y doug
```
The blocked user will not be notified that their messages have been blocked. You can also block or allow all messages with a **mesg** command like one of these:
```
$ mesg y
$ mesg n
```
### write
Another command for sending text without reverting to email is **write**. This command can be used to communicate with a specific user.
```
$ write nemo
Are you still at your desk?
I need to talk with you right away.
^C
```
Enter your text and use **^C** to exit when youre done. The command allows you to send text, but doesnt start a two-way conversation. It just sends the text. If the user is logged in on more than one terminal, you can specify which terminal you want to send the message to or you can rely on the system to choose the one with the shortest idle time.
```
$ write nemo#1
```
If the user you are trying to write to has messages blocked, you should see something like this:
```
$ write nemo
write: nemo has messages disabled
```
### talk/ytalk
The **talk** or **ytalk** command gives you a chance to have an interactive chat with one or more other users. The command will bring up a double-pane (top and bottom) window. Each individual will type into the top portion of the display on their screen and see the responses in the bottom section(s). The respondents can respond to a talk request by typing "talk" followed by the username of the person addressing them.
```
Message from Talk_Daemon@dragonfly at 10:10 ...
talk: connection requested by dory@127.0.0.1.
talk: respond with: talk dory@127.0.0.1
$ talk dory
```
The window can involve more than two participants if **ytalk** is used. As you can see in the example below (the result of the "talk dory" command shown above), talk is often ytalk.
```
----------------------------= YTalk version 3.3.0 =--------------------------
Is the report ready?
-------------------------------= nemo@dragonfly =----------------------------
Just finished it
```
As explained above, on the other side of the conversation, the talk session window panes are reversed:
```
----------------------------= YTalk version 3.3.0 =--------------------------
Just finished it
-------------------------------= dory@dragonfly =----------------------------
Is the report ready?
```
Again, use **^C** to exit.
To talk with someone on another system, you just need to add a **-h** option and the hostname or IP address with a command like this:
```
$ talk -h 192.168.0.11 nemo
```
### Wrap-Up
There are a number of basic commands for sending messages to other logged-in users on Linux systems, and they can be especially useful when you need to send out a quick message to all of the users, prefer a quick exchange to a phone call or want to easily involve more than two people in a quick messaging session.
Some commands, like **wall**, allow a message to be broadcast, but are not interactive. Others, like **talk**, allow both lengthy and multi-user chats, avoiding the need to set up a conference call when a fairly quick exchange of information is all that's required.
Join the Network World communities on [Facebook][2] and [LinkedIn][3] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3530343/communicating-with-other-users-on-the-linux-command-line.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage)
[2]: https://www.facebook.com/NetworkWorld/
[3]: https://www.linkedin.com/company/network-world

View File

@@ -0,0 +1,146 @@
[#]: collector: (lujun9972)
[#]: translator: (linusboyle)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Communicating with other users on the Linux command line)
[#]: via: (https://www.networkworld.com/article/3530343/communicating-with-other-users-on-the-linux-command-line.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
使用Linux命令行与其他用户进行通信
======
使用Linux命令行向其他用户发送消息或许非常容易但你可能会对一些相关的命令感兴趣。在这篇文章中我们会考察4个这样的命令看看它们是怎么工作的。
### wall
**wall**("write all"的简称)命令允许你向所有系统中已登录的用户发送一条信息。这里我们假设用户都使用命令行在一台服务器上工作。虽然wall命令最常被系统管理员用于向用户发布公告和传递信息比如说服务器即将因维护而关闭),但它可以被任何用户使用。
一个系统管理员可能会用类似下面的方式发送信息:
```
$ wall The system will be going down in 15 minutes to address a serious problem
```
而所有登录的用户都将看到类似这样的信息:
```
Broadcast message from admin@dragonfly (pts/0) (Thu Mar 5 08:56:42 2020):
The system is going down in 15 minutes to address a serious problem
```
如果希望在消息中使用单引号,你可以像这样将信息用双引号括起来:
```
$ wall “Dont forget to save your work before logging off”
```
最外层的双引号不会出现在发出的消息中但是如果没有它们wall会停下并等待输入一个配对的单引号。
### mesg
如果出于某种理由你不想接收来自另一个用户的消息,你可以使用**mesg**命令来屏蔽这些消息。这个命令可以接受一个“n”作为参数来拒绝某用户的消息或者接收一个“y”作为参数来接收用户发来的消息。
[][1]
```
$ mesg n doug
$ mesg y doug
```
被屏蔽的用户不会被告知这一事实。你也可以像这样使用**mesg**来屏蔽或者接收所有消息:
```
$ mesg y
$ mesg n
```
### write
另一个用于在不使用电子邮件的情况下发送文本的命令是**write**,这个命令可以用来和一个特定的用户通信。
```
$ write nemo
Are you still at your desk?
I need to talk with you right away.
^C
```
输入你的信息后用**ctrl-c**退出,这样就完成了通信。这个命令允许你发送文本,但并不建立一个双向的通话。它只是将文本发送过去而已。如果目标用户在多于一个终端上登录,你可以指定你想将消息发送到哪一个终端,否则系统会选择空闲时间最短的那个终端。
```
$ write nemo#1
```
如果你试图向一个将消息屏蔽了的用户发送信息,你应该会看到这样的输出:
```
$ write nemo
write: nemo has messages disabled
```
### talk/ytalk
**talk**和**ytalk**命令让你可以和一个或多个用户进行交互式的聊天。它们会展示一个有上下两个子窗口的界面每个用户向他们屏幕上显示在上方的窗口输入内容并在下方的窗口看到回复信息。要回复一个talk请求接收方可以输入“talk”在后面加上请求方的用户名。
```
Message from Talk_Daemon@dragonfly at 10:10 ...
talk: connection requested by dory@127.0.0.1.
talk: respond with: talk dory@127.0.0.1
$ talk dory
```
如果使用的是**ytalk**那么窗口中可以包含多于两个参与者。正如下面的例子所展示的这是上面“talk dory”命令的结果talk通常指向ytalk。
```
----------------------------= YTalk version 3.3.0 =--------------------------
Is the report ready?
-------------------------------= nemo@dragonfly =----------------------------
Just finished it
```
如上所述在通话的另一侧talk会话界面的窗口是相反的
```
----------------------------= YTalk version 3.3.0 =--------------------------
Just finished it
-------------------------------= dory@dragonfly =----------------------------
Is the report ready?
```
同样的,使用**ctrl-c**来退出。
如果要和非本机的用户通讯,你需要加上**-h**选项和目标主机名或IP地址就像这样
```
$ talk -h 192.168.0.11 nemo
```
### 总结
Linux上有若干基本的命令可以用来向其他登录的用户发送消息。如果你需要向所有用户快速发送信息或是需要便捷的电话替代品又或是希望能简单地开始一个多用户快速通讯会话这些命令会十分实用。
一些命令如**wall**允许广播消息但却不是交互式的。另外的一些命令如**talk**允许多用户进行长时间通讯,当你只需要非常快速地交换一些信息,它们可以你你避免建立一个电话会议。
加入在[Facebook][2]和[LinkedIn][3]上的Network World社区来评论你感兴趣的话题。
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3530343/communicating-with-other-users-on-the-linux-command-line.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[linusboyle](https://github.com/linusboyle)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage)
[2]: https://www.facebook.com/NetworkWorld/
[3]: https://www.linkedin.com/company/network-world