How to Block Terminal Broadcast Messages Using the mesg Command in Linux

When you are logged into a multi-user Linux server, administrators or automated system scripts frequently use the wall (write all) command to broadcast urgent messages directly to your terminal screen. While this is helpful for critical announcements (like an impending system reboot), it can be incredibly disruptive if you are in the middle of writing a complex script in nano or analyzing a dense log file, as the broadcast message will literally overwrite the text currently displayed on your screen. To prevent these interruptions, Linux provides the mesg utility to control your terminal’s write access.

How the mesg Command Works

The mesg command is a simple toggle switch that controls whether other users (and certain system processes) are granted permission to write text directly to your current terminal session (your tty).

To check your current status, simply run the command with no arguments:

mesg

The terminal will output one of two things:

  • is y: This means “yes,” write access is currently enabled. Your terminal is open to receiving broadcast messages.
  • is n: This means “no,” write access is disabled. Your terminal will quietly block incoming broadcasts.

How to Block Incoming Messages

If you are about to start a task requiring deep concentration or an uninterrupted screen display, you can disable write access by passing the n (no) flag.

mesg n

If a colleague tries to send you a direct message using the write command while your terminal is set to n, their terminal will return an error stating that you have disabled messages. If the system sends out a wall broadcast, your terminal will silently ignore it, allowing your screen to remain pristine.

Important Note on Root Access: The mesg n command protects you from regular users and standard scripts. However, it cannot block messages sent by the root user. If the root administrator issues a critical system-wide wall broadcast, the kernel will bypass your mesg settings and force the text onto your screen regardless.

How to Re-Enable Messages

Once you have finished your work, it is good etiquette (and often necessary for team communication) to reopen your terminal to messages. You do this by passing the y (yes) flag.

mesg y

This instantly restores standard write access to your tty, allowing you to receive write communications and standard wall broadcasts once again.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.