Unit 5. Communication with other users

INDEX
5.1 write, wall and mesg
5.2 mail, motd and news
π£οΈ Communication with Other Users in Linux: write
, wall
, and mesg.
Linux is a multi-user operating system, and it provides several commands to facilitate communication between logged-in users.
Three essential tools for this purpose are:
πΈ 1. write
β Send a Message to a Specific User.
π Purpose:
The write
command allows one user to send a direct, real-time message to another user logged into the same system.
π§ͺ Syntax:
write username [terminal]
π οΈ Example:
write hardik pts/2
Hello, are you free for a quick discussion?
The message is typed and sent line-by-line. Press Ctrl+D
to end the message.
π Notes:
The recipient must have messaging enabled using
mesg y
.You can find the terminal of a user using the
who
command.
πΈ 2. wall
β Broadcast Message to All Users.
π Purpose:
The wall
(write all) command is used to send a message to all users currently logged in to the system.
π§ͺ Syntax:
wall [message]
π οΈ Example:
wall “System maintenance will start in 5 minutes.”
You can also use wall
with input redirection:
echo “Shutdown in 10 minutes!” | wall
π Notes:
It is commonly used by system administrators to announce important notices.
Users must have message permissions enabled (
mesg y
) to receivewall
messages.
πΈ 3. mesg
β Control Receiving Messages.
π Purpose:
The mesg
command allows users to enable or disable the reception of messages from other users using write
or wall
.
π§ͺ Syntax:
mesg [y|n]
mesg y
β Allow messages.mesg n
β Block messages.
π οΈ Example:
mesg n # Disable incoming messages
mesg y # Enable incoming messages
π Notes:
When
mesg
is set ton
, the user will not receive anywrite
orwall
messages.It is useful for avoiding interruptions during sensitive work.
π¬ Communication with Other Users in Linux: mail
, motd
, and news
Linux, being a multi-user operating system, includes several tools to facilitate system-wide communication.
Among these are tools not meant for real-time messaging but rather for asynchronous or broadcast-style information sharing.
Let’s explore them in detail:
πΉ 1. mail
β Send and Read System Emails
π Purpose:
The
mail
command allows users to send and receive simple text-based emails within the system, usually used for notifications, logs, or communication between users on the same server.
π§ͺ Usage:
mail [username]
π οΈ Example:
mail hardik
Subject: Meeting Reminder
Don’t forget the meeting at 3 PM today.
.
(End the message with a dot .
on a new line.)
To read received mail:
mail
To delete a message inside the mail
interface:
d [message_number]
π Notes:
Often used by the system or cron jobs to notify users.
Messages are stored in
/var/mail/username
or/var/spool/mail/username
.
πΉ 2. motd
β Message of the Day
π Purpose:
The Message of the Day (MOTD) is a static or dynamic message displayed to users after they log in to a terminal session. Itβs typically used to show important announcements, system updates, or warnings.
π§ͺ File Path:
/etc/motd
π οΈ Example:
To set or update the MOTD:
sudo nano /etc/motd
You can write messages like:
β οΈ Scheduled maintenance on Saturday at 9 PM. Please save your work in advance.
π Notes:
Automatically displayed upon user login.
Can be generated dynamically by scripts in
/etc/update-motd.d/
on some distributions like Ubuntu.
πΉ 3. news
β Read System News Bulletins
π Purpose:
The
news
command is used to display system news bulletins that may be posted by administrators or packages.It was more commonly used in older UNIX systems but is still available on some Linux environments.
π§ͺ Usage:
news
π οΈ Example:
Admins place news files in:
/usr/news
Or sometimes in:
/var/news
When a user runs the news
command, they can read any new system bulletins available.
π Notes:
Not commonly used in modern Linux distributions but can be configured manually.
Good for posting policy changes, updates, or announcements.
β Summary Table:
Command | Function | Example |
---|---|---|
write |
Send a message to a specific user | write user pts/1 |
wall |
Broadcast a message to all users | wall "Update at 6 PM" |
mesg |
Enable/disable receiving messages | mesg n to block, mesg y to allow |
Command | Purpose | Notes |
---|---|---|
mail |
Send/read emails within the system | Used for notifications and user messages |
motd |
Display message upon login | Stored in /etc/motd |
news |
Show system bulletins to users | Less common, but useful for admins |