How to communicate with other users on the Linux command line

  • 2021-08-31 09:55:51
  • OfStack

Sending messages to other users on the Linux command line is simple, and many commands can do this. The trouble is that you need to choose a suitable command from many commands to use. So I've chosen four common Linux user communication commands to share with you and show you how they work.

wall

The wall command (meaning write all) allows you to send messages to all users who are logged in to the system. The wall command can be used by any user, but the wall command is typically used by system administrators to send announcements to users (for example, the server will shut down 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 notifications 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 send a message with single quotation marks, you need to enclose the message to be sent in double quotation marks, as follows:

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

In the command shown in the above example, the outermost quotation mark will not be displayed when the message is transmitted, but if there is no outermost quotation mark, the command will wait for a quotation mark paired with the single quotation mark in the sentence to end the sentence.

mesg

If you want to reject a message from a user for some reason, you can use the mesg command. This command should be used with the parameters n or y, respectively, to reject or accept a letter from a user, such as the following (alvin is the user name):

$ mesg n alvin
$ mesg y alvin

It is worth noting that after shielding users with mesg command, shielded users will not receive the notification that they have been shielded, that is to say, shielded users will not know that they have been shielded.

You can also use this command to accept or block communications from all users by omitting the username parameter:

$ mesg y
$ mesg n
write

Another command that can send text messages directly without converting them to e-mail is write. This command can be used to communicate with specific users. For example, if you want to send a message to a user named alvin, you can use the following command:

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

Press ctrl+C to exit after writing the send message. 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 select one terminal you want to transmit or rely on the system to select one terminal that takes the least time to transmit, as follows:

$ write alvin#1

If you are blocked by the user alvin, you will see the following prompt:

$ write alvin
write: alvin has messages disabled
talk / ytalk

The talk and ytalk commands allow you to interact with one or more users, while the talk command only allows you to interact with one user. Both talk and ytalk commands will start a double-page window, and each party who communicates can enter information in the upper page of the window and see response information in the lower page.

The party requested to join the communication can respond to the communication by entering talk followed by the user name of the communication originator, as follows:

Message from Talk_Daemon@dragonfly at 10:10 ...
talk: connection requested by alvin@127.0.0.1.
talk: respond with: talk alvin@127.0.0.1
$ talk alvin

It is worth noting that when the system has both talk and ytalk installed, the talk command is associated with the ytalk command by default, so when you enter talk alvin, the system actually executes ytalk alvin. Since both commands are installed on my system, the output you see after executing the above commands is actually ytalk alvin:

----------------------------= YTalk version 3.3.0 =--------------------------
Is the report ready?
-------------------------------= root@lxlinux =----------------------------
Just finished it

The above is the window information seen by the user alvin, while the window content seen by the other party root is reversed:

----------------------------= YTalk version 3.3.0 =--------------------------
Just finished it
-------------------------------= alvin@lxlinux =----------------------------
Is the report ready?

Similarly, this command is terminated with ctrl+C.

To use this command to communicate with users of other systems, you need to add the parameter-h, which is the host name or IP address. It can be used as follows:

$ talk -h 192.168.0.11 alvin

Summarize

The Linux system has a number of commands that you can use to send information to a logged-in user, These commands are very useful in some situations, such as using wall to broadcast information and using talk to carry out interactive talks between two users. They can make users exchange information quickly. Learning to use these commonly used commands can make communication between users more convenient and improve communication efficiency.


Related articles: