Networking | Programming | Security | Linux | Computer Science | About

Real Time Messaging with Wall and Write

If you want to chat in real time with another user on the system, you can use write. This command is provided for communication between two users.

Writing to one user with write

Its use is fairly simple: initiate a write session to another by using the write command followed by the name of the user you want to talk to. For instance, the following command would initiate a session from the current user to user linda:

$ write linda

Next, write opens a prompt after which the user can type text. This text is displayed line by line on the terminal of the other user. No matter what the user is doing, the text will be displayed, as long as the user has a terminal session that is open. If a user receives a write message from another user, he or she can reply to that by opening his or her own write session.

As an illustration, the following procedure demonstrates how root and linda initiate and terminate a write session:

User linda opens the write session to root, using the command write root. This opens the write prompt, from which linda can type her text:

$ linda@nuuk:~> write root 
write: root is logged in more than once; writing to pts/1 
hi root, I'm having a problem.

At this moment, root receives linda’s message at his console. To reply, he has to press Enter to put away linda’s message first, and then enter the command write linda. Next, he can type his message, thereby establishing an active chat session with linda:

nuuk:~ # 
Message from linda@nuuk on pts/2 at 13:35 ... 
hi root, I'm having a problem.

nuuk:~ # write linda 
hi linda, how can I help you 
We'll, my mouse doesn't react anymore

At the end of the session, both parties that are involved have to use the Ctrl+C key sequence to terminate the session. This will bring them back to their prompts, where they can continue their normal work.

Write to all Users with wall

Another tool for real-time communication is wall. This stands for write all, and you can probably guess that this tool is used to write a message to all users. It works in more or less the same way as write: after entering wall, the user who invokes wall writes a message, which is terminated by using the Ctrl+D key sequence.

This message will show on the console of all users who are currently logged in. It needs no explanation that you should use this tool with care, as it is very annoying for users to receive wall messages frequently.

nuuk:~ # wall 
I'll shut down the system in 5 minutes
Broadcast Message from root@nuuk 
    (/dev/pts/1) at 15:27 ... 
I'll shut down the system in 5 minutes

With wall, you can also send the contents of a text file to other users. For instance,

wall /tmp/ mymessage.txt

would send the contents of mymessage.txt to all users who are currently connected. This function is useful for a system administrator who wants to send a longer message to all users.

Disabling Real‑Time Messages

If you don’t want to receive any messages from other users, use the mesg command. This command works with two arguments only.

mesg n

makes sure that no one can write messages to your console. If you want to open your console again for messages from other users, use

mesg y

Published on Wed 12 March 2008 by Dave Wilson in Linux with tag(s): wall write