In a Linux environment, there are scenarios when multiple users are working on the server simultaneously through SSH. However, sometimes system admin needs to restart or shut down the system due to e.g. system maintenance, kernel upgrade, adding or removing hardware from the server. If this is the case, the system admin should inform all logged-in users to save their work. Email does not fit in this situation, as you first have to find out who is logged in and then sending emails to them. Also, you do not know when the user will read the email. Luckily, there is a Linux command “wall” that allows you to do this easily.
Here, we are going to describe the usage of wall command in Linux. Remember, the wall command works the same for all Linux distributions.
Note: Wall command only displays the message on the Terminal window of logged-in users. Users working only on GUI, with no Terminal window open will not be able to see the messages.
Linux Wall Command
Linux Wall command allows you to send a message or the contents of a file to all the currently logged-in users. If no file or message is specified, wall command reads the message from the stdin (standard input).
Wall Command Syntax
The syntax for wall command is as follows:
$ wall [options] [message-or-filename]
Send a Message to All Users
To send a message to all the currently logged-in users, type wall followed by the message you want to send.
$ wall System is going down for 1-hour maintenance.
This command will send the message to all the logged-in users with a Terminal window open.
Note: For some Linux distributions, you have to execute the above command as super user. Also, if a user has chosen to deny messages to their Terminals (like using the mesg command), then only a sudo user will be able to send messages to their Terminals.
Following are the outputs displayed to two users “linuxways” and “ummara” who are logged-in to the server via SSH. These users are working from the system running Ubuntu and Debian.
The wall command also reads the message from stdin (standard input). To do so, simply type wall and hit Enter.
After that, type any message or messages you want to send to logged-in users. Once you are done typing the messages, press Ctrl+D to send those messages.
this is second line
Here is the output which all logged-in users received on their Terminal.
Send a Message from a File
If there are some messages that you have to repeat often, you can simply type them in a file. When you have to send those messages to the logged-in users, simply call that file with wall command. Remember, you will require sudo privileges if you want to send a message from a file.
For example in the following output, file content has been first shown using the cat command. Then to send the message contained in the file, the filename is passed to the wall command.
These are the outputs (from the file msg.txt) received by the logged-in users.
Send a Message to a Group
Instead of sending the message to all logged-in users, you can send it to only the members of a group who are currently logged in to your system. The syntax is as follows:
$ wall -g [group] [message]
For example, to send a message to a group named “sshusers”, the command would be:
$ wall -g sshusers System is going down for 1 hour maintenance.
All the members of the “sshusers” group who are currently logged in to the server will receive the specified message.
The wall command displays a banner before displaying a message as can be seen in the following screenshot.
To suppress this banner, use the -n option with the wall command:
For example, the following command will only display the specified message while suppressing the banner.
$ wall -n System is going down for 1 hour maintenance.
All the logged-in Terminal users will receive the message without a banner.
View Version Information
To view the version of the wall command, use the following command:
The following output shows the version of the wall utility is 2.34.
Wall is a handy utility that helps a multi-user system admin to quickly notify other users to save their work before a system shutdown or reboots. In this article, we covered how to use the wall command to communicate with logged-in users. Hope you find it interesting and useful.