Site icon DesignLinux

Wall command in Linux

Wall command in Linux

The wall is a command line tool used to show message on the terminals of all logged-in users. wall stands for write all. Generally, it is used by system administrators to announce of maintenance and further use. This guide covers the use of wall command in Linux.

The message sent using wall will display on the terminals of logged-in user and who have terminal open. In a response every user can write the message with the mesg utility.

Broadcasting a Message

Following is the basic syntax of wall command:

wall [OPTIONS] [FILE|MESSAGE]

It is very simple to broadcast the message, invoke wall command followed by the message as an argument:

wall "The system will be reboot in 20 minutes."
Broadcast message from root@linuxize.host (pts/0) (Sun Oct  8 15:12:17 2020):

The system will be reboot in 20 minutes.

It will show the message to the all users who are currently logged in. You can check the currently logged-in users using w command.

Use the -n (--nobanner) option with wall to show only the text to the logged-in users:

wall -n "The system will be restarted in 10 minutes."
The system will be reboot in 20 minutes.

If you want to write multi-line messages, invoke the wall command without an argument:

wall

It will hold until the text entered by you. Press Ctrl+D to end the program and broadcast the message.

You also can use the pipe or string redirection the output of another command to wall. Following the example of echo command to broadcast the multi-line message.

echo "The system will be reboot in 20 minutes. \nPlease close your all programs." | wall

Broadcasting a Message From a File

If you frequently sending same messages, you can define it in separate file and you don’t have to type every time. wall command can read the file if you invoked as root.

Here is the example, how to broadcast the message of a file, run the wall command followed by file name:

wall msg_file.txt
Broadcast message from root@tecnstuff.dev (pts/0) (Sun Oct  8 17:18:06 2020):

The system will be reboot in 20 minutes.

Broadcasting a Message to a Group

To send the message to a specific group members only, invoke the wall command with the -g (--group) option, followed by the group name.

For example, to broadcast message only to the members of the “tns” group, you would run:

wall -g tns "The system will be reboot in 20 minutes."

You also can specify the group id instead of name.

Conclusion

Using the wall command you can send the message to all currently logged-in users.

If you have any questions or feedback, feel free to leave a comment below.

Exit mobile version