🌐 Linux/Unix: Networking & Communication
Estimated reading: 3 minutes 280 views

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:

  1. Find active users and terminals: who Output: alice pts/0 2025-06-15 09:12 bob pts/1 2025-06-15 09:14
  2. Write a message: write bob pts/1 Then type your message. To finish, press Ctrl+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 message
  • d – Delete message
  • q – Quit mail client

To install:

sudo apt install mailutils  # Debian/Ubuntu
sudo yum install mailx      # RHEL/CentOS

Messaging Tools Comparison

ToolPurposeTargetsInteractiveCommon Usage
writeSend message to one userSpecific TTYUser-to-user chat
wallBroadcast to all usersAll TTYsMaintenance alerts, announcements
mailSend/read system emailUser’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 write to chat with individual users in real time.
  • Use wall to send announcements to all active users.
  • Use mail to 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 :
Share

πŸ”΅ Linux/Unix: Messaging (write, wall, mail)

Or Copy Link

CONTENTS
Scroll to Top