Wall command in Linux
wall
is a command-line utility that displays a message on the terminals of all logged-in users. The messages can be either typed on the terminal or the contents of a file. wall stands for write all, to send a message only to a specific user use the write
command.
Usually, system administrators send messages to announce maintenance and ask users to log out and close all open programs. The messages are shown to all logged-in users with a terminal open. Users using a graphical desktop environment with no terminal open will not see the messages. Each user can control the write access to its terminal with the mesg
utility. When the superuser invokes the wall
command, all users receive the messages, no matter their mesg
settings.
Broadcasting a Message
The syntax for the wall
command is as follows:
$ wall [OPTIONS] [<FILE>|<MESSAGE>]
If no file is specified wall
reads the message from the standard input.
The most straightforward way to broadcast a message is to invoke the wall
command with the message as the argument:
$ wall "The system will be restarted in 10 minutes."
OUTPUT
Broadcast message from root@reconshell (pts/0) (Sun Oct 4 19:22:07 2020):
The system will be restarted in 10 minutes.
The message will be broadcasted to all users that are currently logged in.
To see all the logged-in users, run the w or
who
command.
To suppress the banner and show only the text you types to the logged-in users, invoke the command with the -n
(--nobanner
) option:
$ wall -n "The system will be restarted in 10 minutes."
OUTPUT
The system will be restarted in 10 minutes.
If you want to write multi-line messages, invoke the command without an argument:
$ wall
The wall
command will wait for you to enter text. When you’re done typing the message, press Ctrl+D
to end the program and broadcast the message.
You can also use the here-string redirection or pipe the output of another command to wall
. Here is an example showing how to use the echo
command to broadcast multi-line messages:
echo "The system will be restarted in 10 minutes. \nPlease save your work." | wall
Broadcasting a Message From a File
If you are regularly sending the same messages, you can write each one of them to a file, so that you don’t need to re-type the same text. wall
reads from the file only when invoked as root.
To broadcast the contents of a file, invoke the wall
command followed by the file name:
message1_file.txt
OUTPUT
The system will be restarted in 10 minutes.
$ wall message1_file.txt
OUTPUT
Broadcast message from root@linuxize.host (pts/0) (Sun Oct 4 19:25:06 2020):
The system will be restarted in 10 minutes.
Broadcasting a Message to a Group
To send a message only to members of a given group, run the command with the -g
(--group
) option, followed by the group name. For example, to write only on the terminals of the members of the “devs” group, you would run:
$ wall -g devs "The system will be restarted in 10 minutes."
The group can also be specified by its GID (group ID).
Conclusion
The wall
command writes a message on the terminals of all currently logged-in users. Feel free to leave a comment if you have any questions.
Leave a Reply