48. User Management - Communications Between Users
Contents
Linux provides users with tools to communicate with each other. Some can send messages to a specified user; some can send a group of messages; some can even send content as an email to a user’s inbox list.
Send Message to a Specific User
Before we send information to a user, we first need to know which terminal the message receiver is at:
|
|

Check logged in users
When we know the terminal of the message receiver, we can send some messages to the terminal:
|
|

Sending message to a user called user
When the message is sent, the receiving terminal should print out the content just sent out by the root terminal:

Sending message to a user called user
Disable or Enable Messaging Function
We can use the mesg command to turn on or off the ability to send and receive messages.
Here are two arguments for mesg command:
Option | Meaning |
---|---|
n | Disable send and receive functions. This parameter is not valid for messages sent from root. |
y | Enable send and receive functions. |
We can set root to not receive or send messages:
|
|

Disable the send and receive functions
When a user attempts to send a message to root, the system displays that root has disabled the messaging feature:
|
|

The user attempts to send a message to a root user who has turned off the messaging function
Group Messaging Function
We can use the wall command to broadcast messages to all users:
|
|

Send information to all users, including the sender of the message
When the message is broadcasted, the receiving terminals should print out the content just sent out by the root terminal:

Broadcasting message to all users
Output the Message Without the Banner
With the -n option, the message sent does not display the sending host:
|
|

Send information to all users without the banner, including the sender of the message
When the message is broadcasted, the receiving terminals should print out the content just sent out by the root terminal without the banner:

Broadcasting message to all users without the banner
Send an Email to a User
We can send mail to users based on mail, but we first need to install the mailx package:
|
|
We can try sending an email to root:
|
|

Send an email to root
The root user’s terminal should prompt a message:

Received an email
We can view the newly received mail through the mail command:
|
|

Viewing the received email
When we have finished checking the e-mail, we can terminate the program by pressing the Ctrl + D key combination.
References WRITE(1), MESG(1), WALL(1), GNU Mailutils
Author Dong Chen
LastMod Wed Mar 20 2019