Communicating with other users on the Linux command line

Time:2020-9-24

Hello, I’m Liang Xu

Sending information to other users on the Linux command line is easy. Many commands can do this. The trouble is that you need to choose one of the many commands to use. Therefore, I have selected four common Linux user communication commands to share with you and show you how these four commands work.

wall

wallCommand (meaningwrite all)Allows you to send messages to all users who are logged in to the system. Any user can use itwallCommand, butwallCommands are usually used by system administrators to send notification to users (for example, the server will be shut down for maintenance).

A system administrator may send the following information:

$ wall The system will be going down in 15 minutes to address a serious problem

Then, all logged in users can see a notification like this:

Broadcast message from [email protected] (pts/0) (Thu Mar  5 08:56:42 2020):

The system is going down in 15 minutes to address a serious problem

If you have a single quotation mark in the message you want to send, you need to enclose the message in double quotes, as follows:

$ wall "Don't forget to save your work before logging off"

In the command shown in the example above, the outermost quotation marks will not be displayed during information transmission, but if there is no outermost quotation marks, the command will always wait for a quotation mark matched with single quotation marks in the sentence to end the sentence.

mesg

If you want to reject a message from a user for some reason, you can use themesgCommand. The command should be used with parametersnperhapsy, which means rejecting or accepting a user’s letter. The use cases are as follows (Alvin is the user name)

$ mesg n alvin
$ mesg y alvin

It is worth noting that themesgAfter the command blocks users, the blocked users will not receive the notification that they have been blocked, that is to say, the blocked users will not know that they have been blocked.

You can also use this command to accept or shield all users’ communication by omitting the user name parameters:

$ mesg y
$ mesg n

write

Another command that can send text messages directly without having to convert them to e-mail iswrite。 This command can be used to communicate with specific users, for example, if you want to send aalvinTo send information, you can use the following command:

$ write alvin
Are you still at your desk?
I need to talk with you right away.
^C

After writing the message, pressctrl+Csign out. This command allows you to send messages, but instead of opening a duplex channel, it can only be used to send messages. If the receiving user logs in on more than one terminal, you can choose the terminal you want to transmit or rely on the system to select a terminal that takes the least time to transmit, as follows:

$ write alvin#1

If you are a useralvinIf it is blocked, you will see the following prompt:

$ write alvin
write: alvin has messages disabled

talk / ytalk

talkandytalkCommand allows you to establish interaction with one or more users, among whichtalkThe command allows you to establish interactive communication with only one user.talkAndytalkThe command will start a double layout window, and each party of communication can input information in the upper part of the window and see the response information in the lower part of the window.

The Party requested to join the communication can inputtalkAnd then follow the user name of the communication initiator to respond to the communication, as follows:

Message from [email protected] at 10:10 ...
talk: connection requested by [email protected]
talk: respond with:  talk [email protected]

$ talk alvin

It is worth noting that when the system is already installedtalkAlso installedytalkWhen,talkCommand default will beytalkCommands are associated, so when you typetalk alvinAfter that, what the system actually implements isytalk alvin。 Since both commands are installed on my system, the output after executing the above commands is actuallyytalk alvinOf:

----------------------------= YTalk version 3.3.0 =--------------------------
Is the report ready?

-------------------------------= [email protected] =----------------------------
Just finished it

The above are usersalvinSee the window information while communicating with the other partyrootThe window content you see is the reverse:

----------------------------= YTalk version 3.3.0 =--------------------------
Just finished it

-------------------------------= [email protected] =----------------------------
Is the report ready?

Again, this command also usesctrl+CTo terminate.

To communicate with users of other systems with this command, you need to add-hThe parameter value is the host name or IP address. The use cases are as follows:

$ talk -h 192.168.0.11 alvin

summary

Linux system has many commands that can be used to send information to logged in users. These commands are very useful in some situations, such as usingwallBroadcast information withtalkFor interactive talks between dual-purpose users, they can let users exchange information quickly. Learning to use these common commands can make communication between users more convenient and improve the efficiency of communication.

Finally, I hope the content of this article will be helpful to your work. If you have any questions about these commands, please leave a message and let me know!


Official account: good Linux

Communicating with other users on the Linux command line

What is the harvest? I hope the old fellow will take three strikes to show this article to more people.