Linux write command

Updated: 05/04/2019 by Computer Hope
write command

On Unix-like operating systems, the write command sends a message to another user.

This page covers the Linux version of write.

Description

The write utility lets you communicate with other users by copying lines from your terminal to theirs.

When you run the write command, the user you are writing to gets a message of the format:

Message from yourname@yourhost on yourtty at hh:mm ...

Any further lines you enter are copied to the specified user's terminal. If the other user wants to reply, they must run write as well.

When you are done, type an end-of-file or interrupt character. The other user sees the message ‘EOF’ indicating that the conversation is over.

You can prevent people (other than the super-user) from writing to you with the mesg command.

If the user you want to write to is logged in on more than one terminal, you can specify which terminal to write to by specifying the terminal name as the second operand to the write command. Alternatively, you can let write select one of the terminals and it will pick the one with the shortest idle time. So, if the user is logged in at work and also dialed up from home, the message goes to the right place.

The traditional protocol for writing to someone is that the string ‘-o’, either at the end of a line or on a line by itself, means that it is the other person's turn to talk. The string ‘oo’ indicates the person believes the conversation to be over.

Syntax

write user [tty]

Options

user The user to write to.
tty The specific terminal to write to, if the user is logged in to more than one session.

Examples

write hope

Write a message to the user hope. After entering this command, you will be placed on a blank line, where everything you type will be sent to the other user (line by line). Typing the interrupt character (Ctrl-C, by default) returns you to the command prompt and end the write session.

write hope tty7

Write a message to the user hope on terminal tty7.

mesg - Control if (non-root) users can send messages to your terminal.
talk - Talk with other logged in users.
wall - Send a message to all logged-in users.
who - Report which users are logged in to the system.