Home / Alt manpages / write(1)

  • write(1)
  • User command
  • linux

Send a terminal message with write(1) without losing your place

You will send a live message from one Linux terminal to another logged-in user's terminal, confirm which terminal receives it, and close the exchange cleanly. This guide uses the write command shipped by util-linux 2.39.3 on this machine, from the bsdextrautils package.

Allow about five minutes for a two-terminal test. You need the target user's login name, access to a shell, and either a second terminal of your own or a willing recipient. No elevated privileges are needed for ordinary use.

1. Check the installed command

Start by confirming that the command is available and record the version if you are writing instructions or a script around it:

$ command -v write
/usr/bin/write
$ write --version
write from util-linux 2.39.3

The exact version line can vary on another distribution. The important check is that write resolves to an installed executable. This version accepts only the help and version options; the message itself is supplied as input after the user and optional terminal name.

2. Find the recipient and terminal

Use who to see logged-in users and the terminals they occupy:

$ who
alex     pts/2        2026-09-28 10:14 (192.0.2.20)
alex     pts/5        2026-09-28 10:16 (192.0.2.20)

Replace alex below with the actual login name. If that user appears once, you can let write choose the terminal. If the user appears more than once, give the terminal name as the second operand, such as pts/5. The command otherwise chooses the terminal with the shortest idle time, which may not be the one the person is watching.

Before sending anything sensitive, check the name and terminal one more time. write copies what you type to a live terminal. It is not private messaging, encryption, or an audit trail.

3. Open the conversation

To address a user without choosing a terminal, run:

$ write alex

To select one of several terminals, run:

$ write alex pts/5

The recipient sees a header similar to:

Message from sam@host on pts/3 at 10:22 ...

The user and host in that header are determined by the current session. Do not copy the example literally: use the login and terminal values returned by who. Once the command is connected, each line you enter is copied to the selected terminal. Press Enter after each line rather than composing a large block in another application.

4. End the exchange deliberately

When you have finished, send the terminal's end-of-file character. In a normal interactive shell, that means pressing Ctrl-D on an empty input line:

$ write alex pts/5
Please restart the import after 14:00
^D

The recipient should see EOF, indicating that this side has closed the conversation. The recipient cannot reply through the same process. They must run write back to you, using your login name and, if necessary, your terminal from who.

The traditional convention -o at the end of a line means that the other person may take a turn, while oo means the conversation is over. These are conventions carried by the text, not options to the command. Agree on them before relying on them in a longer exchange.

5. Test it safely with two terminals

A second login of your own is the least surprising way to verify the route. In terminal A, identify both sessions:

$ who
sam      pts/3        2026-09-28 10:20
sam      pts/4        2026-09-28 10:21

In terminal A, target terminal B explicitly:

$ write sam pts/4
test message from terminal A
^D

In terminal B, expect the sender header, the test line, and then EOF. If the message appears in the other terminal, repeat the test with the recipient and terminal reversed before using the command for real.

End a session with Ctrl-D, not by closing a terminal window while the command is still active. If you do interrupt it, the recipient may not receive the normal EOF marker. This does not leave a service running, and there is no message queue to clear.

6. Handle blocked or missing terminals

A user can disable incoming terminal messages with mesg. Programs such as nroff and pr may also disable writing temporarily so command output is not overwritten. The superuser is treated differently, but do not use elevated privileges as a routine workaround:

$ mesg
is y
$ mesg n
is n
$ mesg y
is y

The mesg commands change whether other users may write to the current terminal. Restore the previous setting when you are done. If you are the recipient and did not intend to receive messages, use mesg n; if you want to receive them again, use mesg y. These are ordinary per-terminal changes and do not require sudo.

If write reports that the user is not logged in, rerun who and check the spelling. If the user is listed but the terminal is rejected, use the exact terminal name, including its pts/ prefix. If the recipient sees nothing, check that the chosen terminal is still open and that its mesg setting permits messages.

Done means

  • write --version identifies the installed util-linux command.
  • who confirmed the recipient and, where needed, the exact terminal.
  • The message was sent without placing secrets in a shared terminal.
  • The exchange ended with an end-of-file character and the recipient saw EOF.
  • Any temporary mesg change was restored to its previous setting.