In a previous post, we explained how to send a message of the day (MOTD) to all users whenever they log into your server’s shell. It is a perfect way to reach users when they log in, but it will not allow you to send new messages to users who are currently logged in. For that you need a tool called “wall”.
Wall is a small program for Linux and UNIX operating systems that allows you to send real-time messages to all users, useful for broadcasting important alerts or simply communicating with regular shell users.
To send a message to users, first you need to create a text file containing the message. You can use your standard text editor (i.e. vi or nano). For example:
Then type the message: “This is a warning to all users. It’s my birthday!”
Save the message and then type the wall command followed by the file name to send it:
The output on users’ screens will look like this:
Broadcast Message from root@serverschool
(/dev/pts/1) at 18:15 …
This is a warning to all users. It’s my birthday!
Users must have their “mesg” permission set to “yes” in order for them to receive the wall message. Since this is enabled by default, that should not be a problem. Now, you can send messages to users anytime you want, as long as it is 20 lines or less.