When you are managing a multi-user Linux server environment (such as a university lab cluster or a corporate development server), you frequently need to coordinate with other developers who are currently logged into the exact same machine. If a developer is running a massive script that is crushing the CPU, you need a way to instantly contact them. Instead of trying to find their phone number or sending an email they might ignore, you can use the write command to forcefully inject a text message directly onto their active terminal screen.
How the write Command Works
Unlike modern chat applications, the write command is a highly primitive, one-way terminal interrupt. It physically writes your text directly onto the target user’s command line interface, completely bypassing their shell prompt.
To use the command, you first need to know exactly who is currently logged into the server. You can find this out by typing the who command and pressing Enter. The server will output a list of active users, looking something like this:
jsmith pts/0 2024-11-12 14:32
tjones pts/1 2024-11-12 15:45
In this example, the user tjones is logged into terminal pts/1. If you want to send them a message, simply type the command followed by their exact username:
write tjones
Sending Your Message
When you press Enter, your terminal will drop down to a blank line. You are now in “message mode.” Anything you type here will be instantly transmitted to the other user’s screen character by character.
Type your message, for example: “Hey, your massive database query is crashing the server. Please kill the process immediately.”
To finish the message and terminate the connection, press Ctrl + D. The system will append the word EOF (End of File) to the bottom of the message on the target’s screen, indicating that you have successfully disconnected.
Managing Specific Terminals
If a highly active user is logged into the server multiple times simultaneously across several different SSH sessions (e.g., tjones is on both pts/1 and pts/2), simply typing write tjones will blast the message to whichever terminal happens to have the most recent activity. This is highly unreliable.
To ensure your message hits the exact window they are currently looking at, you must explicitly declare the terminal ID directly after the username:
write tjones pts/1
This guarantees the interrupt is routed directly to their primary SSH session window.