LinuxCommandLibrary

write

Send messages to another logged-in user

TLDR

Send a message to a given user on a given terminal ID

$ write [username] [terminal_id]
copy

Send message to "testuser" on terminal /dev/tty/5
$ write [testuser] [tty/5]
copy

Send message to "johndoe" on pseudo terminal /dev/pts/5
$ write [johndoe] [pts/5]
copy

SYNOPSIS

write user [tty]

user: The login name of the user to whom you want to send a message.
tty: Optional. The terminal name (e.g., pts/0, tty1) if the user is logged in multiple times and you want to send to a specific terminal. If omitted, write sends to the most recently logged-in terminal, or prompts if multiple are available.

DESCRIPTION

write is a simple command-line utility in Unix-like operating systems that allows one logged-in user to send text messages directly to another logged-in user's terminal. When you use write, the text you type is displayed immediately on the recipient's screen, interrupting their current activity. This makes it suitable for short, urgent notifications. The communication is one-way from the sender to the receiver.

To use write, both users must be logged in to the same system, and the recipient's terminal must be set to allow messages (controlled by the mesg command). Messages are terminated by pressing Ctrl+D on a new line. It's a direct and immediate form of inter-user communication, distinct from email or more sophisticated chat applications, designed for simple, real-time interaction on a multi-user system.

CAVEATS

  • The recipient must be logged in to the same system and their terminal must be configured to accept messages (using mesg y). If not, write will inform you that the user is not logged in or that permissions are denied.
  • Messages appear directly on the recipient's screen, potentially interrupting their work. This can be disruptive.
  • It is not suitable for long conversations; for interactive chat, consider using talk.
  • Messages are not buffered; they are sent character by character or line by line depending on the system, making them appear immediately.

ENDING A MESSAGE

To finish your message and send it, press Ctrl+D on a new line. You can also press Ctrl+C to abort the message without sending it.

CHECKING MESSAGE PERMISSIONS

You can check your current message reception status using the command mesg. Use mesg y to allow others to write to your terminal and mesg n to prevent it.

HISTORY

The write command is one of the oldest utilities in Unix-like operating systems, dating back to the early days of Unix. It provided a fundamental means for users sharing a multi-user system to communicate directly. Its simplicity and immediacy made it a staple for system administrators to send quick notices or for users to coordinate. While largely superseded by modern chat applications and email for general communication, write remains a core utility available on virtually all Linux and Unix systems.

SEE ALSO

talk(1), wall(1), mesg(1), who(1)

Copied to clipboard