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 16.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?
sages.

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 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.

wall

For example, here's the first step when the text is entered on stdin:

How to use wall command

Here's the second step when Ctrl+D is pressed multiple times, and the message is broadcasted:

Using Linux wall command to inform users

And here's how other logged in users see the message:

Wall message as seen by the user

Q2. How to strip 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

For example, the following action:

wall -n
Message without header
^D

Produced the following output:

How to strip header from broadcasted message

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.

wall [filename]

For example:

wall input.txt

Where input.txt contains the following line:

This message is from a file

How to make wall accept input from file

And here's the output:

Wall 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"

Conclusion

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.

Share this page:

Suggested articles

1 Comment(s)

Add comment

Comments

From: 110120 at: 2018-05-11 15:48:12

very thanks