In a Linux environment, there are situations 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.
The fact here is that there is a Linux command "wall" that allows you to do this easily.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform important Linux related queries.
In this context, we shall look into how to use wall command in Linux.
Also, the wall command works the same for all Linux distributions.
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).
Note that 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.
The command syntax for wall command is shown below:
$ wall [options] [message-or-filename]
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.
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 first line
this is second line
The output will enable all logged-in users see the message on their Terminal.
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:
$ sudo wall <filename>
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.
To suppress this banner, use the -n option with the wall command:
$ wall -n <message>
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.
To view the version of the wall command, use the following command:
$ wall -V
The output shows the version of the wall utility.
This article covers how Wall command works in Linux. 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.
Here, you will see some examples of how to use the wall command to communicate with logged-in users.
There are times when multiple users are logged in to a server computer, and you - the system/network admin - need to, say, restart the server to perform some maintenance task.
Of course, the correct way is to inform all those who are logged in about the maintenance activity.
In Linux, there is a built in command line utility for this purpose called Wall.
What is wall command in Linux ?
As already mentioned, the wall command is used to send a message to all logged in users.
It's syntax is:
$ wall [-n] [-t TIMEOUT] [file]
How to use wall command?
Basic usage is very straight forward - just execute the 'wall' command and write the message you want to transmit on the standard input.
Once done, use the Ctrl+D key combination to signal the command that you're done writing the message:
How to remove header from broadcasted message?
In case you want to remove the header that appears with the broadcasted messages, you can do that using the -n command line option:
$ wall -n