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 receive wall 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 to n, the user will not receive any write or wall 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

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.