The wall command in Linux – Everything you need to know

Wall command in linux

Wall command in Linux lets you broadcast messages across the terminals of currently logged-in users. You can send messages by typing out the message on the terminal or send a text from a file as the broadcast message. In this tutorial, we will learn how to use the wall command for broadcasting messages in Linux.

Preparing to use the wall command

Before we start, let’s create a dummy user for testing the wall command. We will broadcast the message from one terminal and receive it on the other terminal.

To create a user use adduser command:

adduser jayant 

To switch to this user, use the su command :

su jayant

To display the current user, use whoami command:

whoami

Output :

jayant

Let’s open two terminal windows with different users logged-in. After we have done this, we can start using the wall command.

How to use the wall command to broadcast messages?

To broadcast messages using the wall command, run the following command :

wall "This is a sample message"

Output:

Terminal 1 1
Sender’s terminal

The terminal screen of the other logged-in user looks like:

Terminal 2 1
Logged-in User’s terminal

The first line in the output is:

Broadcast message from root@localhost (pts/1) (Sun Nov 15 03:33:48 2020):     

This is the banner that is sent along with the message. This banner includes information regarding the sender along with the date and time from when the message was sent.

You can broadcast messages without this banner as well. Let’s learn about that in the next section.

How to broadcast messages without the banner?

To broadcast messages without the banner use the -n flag along with the wall command.

wall -n "This is a sample message"

Output:

This is a sample message

This is the output that we get on both the terminals.

You can also broadcast text from a file. Let’s learn about this in the next section.

How to broadcast text from a file using the wall command?

To broadcast text from a file we just have to mention the name of the file along with the wall command.

Let’s create a file that we can use to broadcast.

cat > broadcast.txt
This is a sample message stored inside a file.
^C

To check the contents of the file use the cat command as shown below:

cat broadcast.txt

Output :

This is a sample message stored inside a file.

To broadcast this file, use :

wall broadcast.txt

Output :

Broadcast message from root@localhost (pts/1) (Sun Nov 15 03:36:06 2020):      
                                                                               
This is a sample message stored inside a file.      

This is the output that all the logged-in users get.

Conclusion

This tutorial was about wall command in Linux. We learnt how to use this command to broadcast messages and text files across the terminals of all the logged-in users. Broadcasting can be useful for delivering alerts to all the users at one go.