Linux/Unix: Messaging Commands β write, wall, mail Explained with Output & Examples
Introduction β Why Learn Messaging Commands in Linux?
In multi-user Linux/Unix environments, messaging between logged-in users or sending system-wide announcements is crucialβespecially on servers and remote systems. Tools like write, wall, and mail allow communication right from the terminal without requiring external apps.
In this guide, youβll learn:
- How to send private messages to another terminal user with
write - How to broadcast messages to all users with
wall - How to send and read system email with
mail - Real examples and expected outputs
1. write β Send a Message to Another Logged-In User
What is write?
The write command sends a direct message to another logged-in userβs terminal session.
Syntax:
write [username] [tty]
How to Use:
- Find active users and terminals:
whoOutput:alice pts/0 2025-06-15 09:12 bob pts/1 2025-06-15 09:14 - Write a message:
write bob pts/1Then type your message. To finish, pressCtrl+D.
Receiver (bob) sees:
Message from alice@hostname on pts/0 at 09:20 ...
Hey Bob! Please check your email. Thanks.
If you skip tty, it goes to the user’s first active session.
2. wall β Broadcast Message to All Logged-In Users
What is wall?
wall (write all) broadcasts a system-wide message to all logged-in terminals.
Syntax:
wall [file]
Or enter interactive mode:
wall
[Type message here, end with Ctrl+D]
Example:
wall <<EOF
System maintenance at 11:00 PM.
Please save your work.
EOF
Output on all terminals:
Broadcast message from root@server (pts/0) at 21:45 ...
System maintenance at 11:00 PM.
Please save your work.
Requires write permissions enabled on terminals (mesg y).
3. mail β Send & Read System Email
What is mail?
mail sends and reads messages via the local mail systemβoften used for automated alerts or system notifications.
Syntax:
mail [user]
Example 1: Send a message to a user
echo "Backup completed successfully." | mail -s "Backup Report" bob
Example 2: Check your inbox
mail
Output:
Heirloom Mail version 12.5. Type ? for help.
"/var/mail/alice": 1 message 1 new
>N 1 bob Mon Jun 15 10:05 16/512 "Backup Report"
Inside mail:
1β View messagedβ Delete messageqβ Quit mail client
To install:
sudo apt install mailutils # Debian/Ubuntu
sudo yum install mailx # RHEL/CentOS
Messaging Tools Comparison
| Tool | Purpose | Targets | Interactive | Common Usage |
|---|---|---|---|---|
write | Send message to one user | Specific TTY | User-to-user chat | |
wall | Broadcast to all users | All TTYs | Maintenance alerts, announcements | |
mail | Send/read system email | Userβs inbox | (shell) | System logs, job alerts, cron output |
Summary β Recap & Next Steps
Messaging commands help Linux users and admins communicate instantly, alert others, and manage system notificationsβespecially in remote or multi-user server environments.
Key Takeaways:
- Use
writeto chat with individual users in real time. - Use
wallto send announcements to all active users. - Use
mailto send/read system messages, especially in automation.
FAQs
How do I prevent messages from appearing in my terminal?
Run:
mesg n
How do I allow messages again?
Use:
mesg y
Where are mail messages stored?
Usually in /var/mail/<username> or /var/spool/mail/<username>.
Can mail send emails to external addresses?
Yes, but you must configure Sendmail or Postfix.
What’s the difference between wall and write?
write is one-on-one, wall sends to all logged-in users.
Share Now :
