How to send messages or chat in Linux

This tutorial explains how to chat in Linux without installing and using any third party tool or software. Learn how the write, wall and mesg commands are used to send the messages to other logged-in users at the terminal.

There are plenty of rich programs available in Linux that offer chat over the network. However, if you only need a basic program or tool that allows communication between logged-in users on the system, there is no need to install any additional program or third party tool.

Linux inbuilt commands; the write and the wall are sufficient for this purpose. The write command allows us to send message and chat in real time with another user on the system. The wall command allows us to send messages to all users simultaneously.

How the write command and the wall command work

Linux is a multiuser system. It allows several users to login and work simultaneously. To keep a user’s activity separate from other users, session is used. When a user logs in, Linux assigns a new session to that user and uses this session to track, log and monitor his activities.

The write command and the wall command use a fairly simple mechanism. Both commands take message from one session and deliver it to other sessions. The difference between both commands is that the write command deliver message to one session while the wall command deliver it to all sessions.

Following figure shows how the write command delivers the messages.

write command example

Following figure shows how the wall command delivers the messages.

wall command example

Key points
  • Both commands are Shell inbuilt and do not require any additional configuration or setup before use.
  • Both commands only send messages. It means to reply a received message, user need to use the same command again.
  • Both commands deliver messages only between the active users. It means these commands can’t be used to send messages to a user who is logged off.
  • Both commands use Shell sessions to deliver the messages. It means these commands can’t be used to deliver the messages to a network user or a user who is located outside the system.

LAB Setup for practice

Create few user accounts, if not created already, and login from these accounts. Use virtual consoles to login simultaneously.

multiple users login

Sending message to all users

To send a message to all users, use the command wall (stands for write all). The usage of wall command is relatively simple. Type wall at command prompt and write the message. You can use any symbol, character or white space in message. You can write the message in multiple lines too. After typing message, use ctrl+d to send it to all users. This message will show on the terminal of all users who are currently logged in.

sending message to all users

Chatting at terminal or Sending message to an individual user

To send a message to an individual user, use the command write. To use the write command, type write at command prompt followed by the name of the user you want to send message to. For example, if the user c want to send message to the user a, he will use following command

[c@localhost ~]$write a

This command initiates a chat session that captures whatever the user a type at the command prompt line by line and delivers that at the command prompt of the user b. No matter what the user a is doing, message will be displayed at his terminal, as long as he has an active session. To dismiss the received message, user a has to press the Enter key. If user a wants to reply, he has to start his own chat session by typing the following command.

[a@localhost ~]$write c

To terminate or close both chat session, both users need to press ctrl+c keys combination.

This entire process can be divided in three steps; initiating/starting the chat, chatting and terminating/ending the chat. Let’s understand this process with an example. Suppose two users; c and a want to chat.

Initiating/starting the chat

Since the command write allows chat only with the user who is logged in, user c executes the command who. The command who print the list of all logged in users. From the output of who command, the user c confirms that the user a is logged in.

User c types write a at the command prompt and hits the Enter key. This brings the chat prompt for the user c. Then the user c types his message and hits the Enter key again. This time, the write command takes the typed message and prints it to the command prompt of user a.

As mentioned above, the write command only delivers the messages. It doesn’t accept the reply of messages. So, if the user a wants to reply, it has to open its chat session separately. To do this, user a first dismisses the received message by pressing Enter key and then it types write c at the command prompt and hits the Enter key to start its chat session.


Once chat sessions are started from both ends, they can exchange messages. To send a message in active chat session, they only need to hit the Enter key.

Terminating/ ending the chat

Once the chat is over, they can terminate the chat sessions by pressing the ctrl+c keys.

Following figure explains this example step by step.

chat in linux at command prompt

Stopping/controlling the chat or messages

Since the write command delivers the messages without any prior notification interrupting the running tasks, sometime it becomes very annoying. Suppose a user is editing critical configuration file and he receives a useless message from other user just in the middle of editing, how will he feel?

Luckily, the write command allows us to control the incoming messages. If you don’t want to receive any messages, simply turn off the incoming messages by the command mesg.

The use of mesg command is fairly simple. To turn off the incoming messages, use mesg n command and to turn on it again, use mesg y command.

Following figure shows an example of this command.

stop receiving messages linux command prompt

That’s all for this tutorial. If you like this tutorial, please don’t forget to share it with friends through your favorite social network.

ComputerNetworkingNotes Linux Tutorials How to send messages or chat in Linux