Cyberithub

9 Useful wall command examples on Linux{Displays a Message}

Advertisements

In this article, we will look into 9 Useful wall command examples on Linux. Many times you might have seen a scenario where a Linux Administrator needs to send some important messages related to security patches, maintenance work, change in some organization policies etc to all currently logged in users. These kind of tasks can be easily done using an open source utility called wall. This utility is used to display a message or content of a file to all currently logged in users.

Most of the time you will see broadcast messages from superuser account only as it can broadcast messages to those users also who has locally denied the messages from his/her account. We will some real world examples of wall command in below section.

9 Useful wall command examples on Linux

Useful wall command examples on Linux

Also Read: 21 Popular Flatpak command examples on Linux

Example 1: How to Check wall command version

If you want to check wall command version then you need to use wall -V command as shown below.

root@localhost:~# wall -V
wall from util-linux 2.34

 

Example 2: How to Broadcast Messages with Banner

If you want to broadcast message with banner to all logged in users then you need to simply use wall <message> command. In this example we are broadcasting "This is a sample message" using wall "This is a sample message" command.

root@localhost:~# wall "This is a sample message"

Broadcast message from root@localhost (pts/1) (Thu Jun 3 23:35:52 2021

This is a sample message

 

Example 3: How to Broadcast Messages without Banner

If you want to broadcast message without banner then you need to use -n option with wall utility as shown below. This option will suppress the Banner. More on wall utility Man Page.

root@localhost:~# wall -n "This is a sample message"

This is a sample message

 

Example 4: How to Broadcast Messages from a File

You also have the option to broadcast message from a file using wall command. For example, we have created a file called message.txt using vi editor and added a line "This is a Sample Message" as you can see below.

root@localhost:~# vi message.txt
This is a Sample Message

Now to broadcast this message you need to use wall message.txt command as shown below.

root@localhost:~# wall message.txt

Broadcast message from root@localhost (pts/1) (Fri Jun 4 01:17:18 2021

This is a Sample Message

 

Example 5: How to Broadcast Multi Line messages using wall command

If you want to send multi line messages then you need to first write your complete message and then Press Ctrl+D to broadcast that message to all the users.

root@localhost:~# wall
this is a sample file

Broadcast message from root@localhost (pts/1) (Fri Jun 4 01:51:09 2021

this is a sample file
hello from Cyberithub

 

Example 6: How to Broadcast Messages to a Group

In case you want to broadcast messages to a group instead to a user, you can use -g option with wall command. In this example, we are sending This is a Sample Message to cyberithub group using wall -g cyberithub This is a Sample Message command as shown below.

root@localhost:~# wall -g cyberithub This is a Sample Message

 

Example 7: How to Use wall command with echo

If you want you can also use wall command with echo command. The output of echo command can be passed as an input to wall command to broadcast messages as shown below.

root@localhost:~# echo "This is a sample message" | wall

Broadcast message from root@localhost (pts/1) (Fri Jun 4 02:19:53 2021

This is a sample message

 

Example 8: How to Check all the options available with wall command

If you want to check all the options available with wall command then you need to use wall --help command as shown below.

root@localhost:~# wall --help

Usage:
wall [options] [<file> | <message>]

Write a message to all users.

Options:
-g, --group <group> only send message to group
-n, --nobanner do not print banner, works only for root
-t, --timeout <timeout> write timeout in seconds

-h, --help display this help
-V, --version display version

For more details see wall(1).

 

Example 9: How to Check the Man Page of wall command

If you want to check the man page of wall command then you need to use man wall command as shown below.

root@localhost:~# man wall
WALL(1) User Commands WALL(1)

NAME
wall - write a message to all users

SYNOPSIS
wall [-n] [-t timeout] [-g group] [message | file]

DESCRIPTION
wall displays a message, or the contents of a file, or otherwise its standard input, on the terminals of all currently logged in users. The com‐
mand will wrap lines that are longer than 79 characters. Short lines are whitespace padded to have 79 characters. The command will always put a
carriage return and new line at the end of each line.

Only the superuser 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 set-user-ID or set-group-ID.

Leave a Comment