The wall command is a perfect way to send a message to all logged on users on a Linux machine. This is used when you shutdown to alert all users that the system will be shutting down. The example below shows me sending the output of the ps command to all users.
ubuntu@ip-172-31-20-234:~$ sudo ps | wall Broadcast Message from ubuntu@ip-172-3 (/dev/pts/0) at 10:41 ... PID TTY TIME CMD 14307 pts/0 00:00:00 sudo 14309 pts/0 00:00:00 ps |
Here is a more useful example, this shows how to alert your users of upcoming server maintenance.
ubuntu@ip-172-31-20-234:~$ sudo echo "The server will be rebooting in approximately 15 minutes, please save your work." | wall Broadcast Message from ubuntu@ip-172-3 (/dev/pts/0) at 10:46 ... The server will be rebooting in approximately 15 minutes, please save your work. |
This is a perfect way to alert users on terminals that the server will be experiencing maintenance.
If you use the -n parameter to the wall command, you can hide your identity. This could be fun… You must be root to use the nobanner option though.
root@ip-172-31-20-234:/home/ubuntu# echo "Hello" | wall -n Hello |
Try this out in a script, a user could have an alert that sent out messages when disk space was running low, this could be very useful indeed.