bsd-write
Send messages to another logged-in user
SYNOPSIS
write user [tty]
PARAMETERS
user
The username of the recipient to whom the message will be sent. This user must be logged in to receive the message.
tty
(Optional) The specific terminal device name (e.g., `pts/0`, `ttyS0`) to which the message should be sent. This is useful if the target user is logged in multiple times and you want to target a specific session or terminal.
DESCRIPTION
The `bsd-write` command, typically invoked simply as `write`, allows one logged-in user to send real-time text messages directly to another logged-in user's terminal. This is a very old and simple form of inter-user communication on Unix-like systems. When you execute `write user`, the system waits for you to type your message. Each line you type is immediately displayed on the target user's terminal. The message is terminated by an end-of-file character, commonly Ctrl+D, on a new line. If the target user is logged in multiple times, `write` will usually pick the terminal with the shortest idle time to send the message. You can explicitly specify the target terminal by using `write user tty_name` (e.g., `write john pts/0`). A crucial requirement is that the recipient must have allowed messages (i.e., their `mesg` setting is `y`). If messages are blocked, the sender will be notified. It's primarily used for short, quick communications among users on the same system.
CAVEATS
The recipient must be logged in and have messages enabled (i.e., their `mesg` setting is `y`). If `mesg n` is set, they will not receive the message, and the sender will be notified. Messages are sent line by line as they are typed, not as a single block. The command is not suitable for sending sensitive information as messages are unencrypted and directly displayed on the target terminal. It can be disruptive if used inappropriately, as it directly prints to the user's active screen, potentially interfering with their work.
ENDING A MESSAGE
After typing your message, you must press Ctrl+D on a new line (or at the beginning of a line) to send the message and exit the `write` command. Until Ctrl+D is pressed, the command remains active, and anything you type is forwarded.
PERMISSIONS AND ACCESSIBILITY
For `write` to function, the sender must have appropriate write access to the recipient's terminal device. This access is typically managed by the system and is usually granted by default when a user has their `mesg` setting enabled. The `mesg` command itself is used by users to control this permission on their own terminal.
HISTORY
The `write` command is one of the oldest utilities in Unix, dating back to its very early versions. It was a fundamental tool for basic inter-user communication in multi-user environments before the widespread adoption of more sophisticated messaging systems. Its core functionality has remained largely unchanged for decades, reflecting its simple and effective design for direct terminal-to-terminal messaging. The `bsd-write` name often refers to the implementation that originated from BSD Unix, which is commonly adopted in many Linux distributions due to its robustness and adherence to traditional Unix principles.