Qadry
unixcop Admin

How to use wall command in linux

wall is (an abbreviation of write to all) is a Unix command-line utility that displays the contents of a computer file or standard input to all logged-in users. It is used by root to send out shutting down message to all users just before poweroff.

It displays a message on the terminals of all logged-in users. The messages can_be either typed on the terminal or the contents of a file.

Also usually, system administrators send messages to announce maintenance and ask users to log out and close all open programs.The messages ‘re shown to all logged in users with a terminal open.

Broadcasting a Message

“The syntax for the wall command”

wall [OPTIONS] [MESSAGE]
wall [OPTIONS] [FILE]

To broadcast a message is to invoke the wall command with the message as an argument as shown:

[root@unixcop ~]# wall "The system will be restarted in 40 minutes."
                                                                               
Broadcast message from root@unixcop (pts/0) (Sun Sep 26 22:15:07 2021):        
                                                                               
The system will be restarted in 40 minutes.
                                                                               
[root@unixcop ~]#

The message will_be broadcasted to all users that logged in.

Note: To see all the (logged in) users, exclude the w or who commands.

To suppress the banner and show only the text you types to the logged-in users, use the command with the -n (–nobanner) option:

Example:

[root@unixcop ~]# wall -n "The system will be restarted in 40 minutes."
                                                                               
The system will be restarted in 40 minutes.
                                                                               
[root@unixcop ~]#

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

wall

Example:

[root@unixcop ~]# wall
Hi unixcop visitors..
Hi unixcop team...
Hello world..
                                                                               
Broadcast message from root@unixcop (pts/0) (Sun Sep 26 22:32:04 2021):        
                                                                               
Hi unixcop visitors..                                                                  
Hi unixcop team...                                                             
Hello world..                                                                  
                                                                               
[root@unixcop ~]#

The wall command will wait for you to enter text. When you done with typing your lines the message, press Ctrl+D to end the program and review your lines as a message.

Broadcasting a Message From a File

To broadcast the contents of a file, exclude the wall command followed by the file name

Example:

[root@unixcop ~]# wall unixcop
                                                                               
Broadcast message from root@unixcop (pts/0) (Sun Sep 26 22:22:21 2021):        
                                                                               
Hello unixcop visitors                                                         
                                                                               
[root@unixcop ~]#

Broadcasting a Message to a Group

Also to send a message only to members of a given group, run the command with the -g (–group) option, followed by the group name.

Example:

wall -g unixcop_team "Hello Unixcop-team .. are you ready?"

Note: The group can also be specified by its GID (group ID).

Conclusion

The wall command broadcasts a message to the terminals of all (logged in) users at real time. wall reads the message from standard input by default when the filename is omitted.

That’s all !!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

x