Linux wall Command Tutorial for Beginners (with Examples)
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.
Thankfully, Linux offers a built-in command line utility for this purpose. The tool in question is Wall, and in this tutorial, we will discuss the basics of this tool using some easy-to-understand examples. But before we do that, it's worth mentioning that all examples in this article have been tested on an Ubuntu 22.04 LTS machine.
Linux wall command
As already mentioned, the wall command is used to send a message to all logged-in users. Following is its syntax:
wall [-n] [-t TIMEOUT] [file]
And here's how the tool's man page describes it:
Wall displays the contents of file or, by default, its standard input, on
the terminals of all currently logged in users. The command will cut over
79 character long lines to new lines. Short lines are white space padded
to have 79 characters. The command will always put carriage return and
new line at the end of each line.
Only the super-user can write on the terminals of users who have chosen
to deny messages or are using a program which automatically denies mes?
Reading from a file is refused when the invoker is not superuser and the
program is suid or sgid.
Following are some Q&A-styled examples that should give you a good idea on how the wall command works.
Q1. How to use wall command?
Basic usage is very straightforward - 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.
For example, here's the first step when the text is entered on stdin:
Here's the second step when Ctrl+D is pressed multiple times, and the message is broadcasted:
And here's how other logged-in users see the message:
Q2. How to strip the header from the 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.
For example, the following action:
Message without header
Produced the following output:
Q3. How to make wall accept input from file?
This can be achieved by passing the name of the file as input to the wall command.
Where input.txt contains the following line:
This message is from a file
And here's the output:
Q4. What are other ways to use wall command?
There exist some other ways as well in which you can use the wall command. For example:
echo "test message" | wall
wall << .
> test message
wall <<< "test message"
To conclude, the wall command is a must-know if you are system/network admin, and most of your work involves managing headless servers that multiple users use. We've discussed most features of the wall command. To learn more, head to the tool's man page. Also check out our cd command tutorial.