Controlling terminal messaging on Unix: Which command can a user employ to allow or restrict incoming write/wall messages to their terminal session?

Difficulty: Easy

Correct Answer: mesg

Explanation:


Introduction / Context:
On multiuser systems, terminal-to-terminal messaging (for example, write or wall) can interrupt your work. Unix provides a per-terminal permission toggle to allow or deny such messages, giving users control over their session’s privacy and noise level.



Given Data / Assumptions:

  • The user wants to control whether others can send messages to their terminal.
  • We are dealing specifically with write/wall permissions, not email.
  • Standard POSIX userland tools are available.


Concept / Approach:

The mesg command enables or disables message reception on the current terminal. Use mesg y to permit and mesg n to deny. This setting affects utilities like write and wall that attempt to output to your terminal device.



Step-by-Step Solution:

Identify the control utility: mesg.To block: mesg n; to allow: mesg y.Check current state by running mesg without arguments (varies by implementation).Combine with who or tty to identify terminals if you have multiple sessions.


Verification / Alternative check:

Ask a colleague to write to you: if mesg n is set, they will receive a “Message to user not allowed” error. Switching to mesg y immediately permits incoming messages, confirming the setting works per terminal.



Why Other Options Are Wrong:

  • grep: Text search; does not control terminals.
  • halt: Shuts the system down; unrelated to messaging.
  • sleep: Pauses execution for a set time; not a permission control.
  • None of the above: Incorrect because mesg is the correct utility.


Common Pitfalls:

Forgetting that mesg applies to the current terminal only; blocking messages on one session does not affect others. Also, utilities like wall (broadcast) may be restricted by system policy independently of mesg on some systems.



Final Answer:

mesg

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion