wall Command in Linux | Explained

The wall command in Linux allows you to send broadcast messages to all the systems connected (using the SSH) to your system. It could be highly useful for sending warnings like the server is going for maintenance after a specific time or something like that. 

The wall command also goes by the name “write all”, and it is a handy tool for system administrators to communicate with the connected users. The message is displayed only on the terminal and there will be nothing displayed if the terminal is closed. It can also read the text from a file and send it. 

The “SSH” stands for “Secure Shell”, which connects with remote systems and the connection must be made using it to use the wall command. A few steps must be performed to set it up, as discussed Enable SSH on Ubuntu.

This detailed guide will shed light on the details of the “wall command in Linux.”

Covered Content

How to Install the wall Command in Linux?

The wall command comes pre-installed with the system utilities in Linux. However, a few users reported the error “wall command not found” because it is not installed or is manually removed. To install the wall command in Linux, use the following commands according to the distro you are using:

sudo apt install bsdutils #Ubuntu/Debian
sudo pacman -S util-linux #Arch Linux
sudo dnf install util-linux       #Fedora
sudo yum install sysvinit-tools #CentOS

Understanding the wall Command in Linux

The basic syntax of the wall command is as follows:

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

Here, 

  • The “wall” keyword triggers the wall command.
  • The “options” or flags specify the behavior of how the wall command will work.
  • The “<file> | <message>” specifies what message is to be sent.

Let’s take a look at the options/flags of the wall command of Linux.

OptionsDescription
-g or –group <group name>You can send messages to the specified group of connected users using this option. You can also use Group ID or GID.
-n or –nobannerMake the wall command not to print the banner. It can only be used by a root or a user having the sudo privileges.
-t or –timeout Using this option, you can specify the time (in seconds) before the message is automatically discarded. Think of it as the timer.
-h or –helpOutputs the help.
-V or –versionDisplays the installed version of the wall command.

How to Use the wall Command in Linux?

This section discusses the use of the wall command of Linux in detail via the following examples. But before that, you must enable and use the SSH to connect with a remote system, as explained in this guide.

Example 1: Send Broadcast Message Using the wall Command in Linux

To send messages without any option/flag of the wall command in Linux, run the below command and replace “<message>” with your message:

wall <message>

The practical demo of the above command is as follows:

wall "the system will turn off in 5 minutes"

The remote system will receive the following notification message on the terminal:

Here, 

  • The wall command displays where the message was sent from “itslinuxfoss@itslinuxfoss”.
  • The “(pts/1)” represents that the connection was made using the ssh.
  • It also displays the time & date on which the message was delivered. 

Example 2: Send Broadcast Messages to a Group Using the wall Command in Linux

To send a message to the group of users via the wall command of Linux, use the “-g” flag. For instance, we are sending the message to the “sudo” group using the following command:

wall -g sudo "The system is about to reboot"

In the above example, the “-g sudo” specifies the group (sudo) of users to whom the message is being sent.

The members of the sudo group will see the following message on their terminals:

The above broadcast message is sent to all connected users. It will only be displayed in the terminal. It also displays the time & date on which the message was sent.

Example 3: Send Broadcast Message Without Banner Using the wall Command in Linux

To send only the message without the default text that appears with the message (sender’s username, date, and time), use the “-n” or “–nobanner” option/flag of the wall command. Please note that using the “-n” option, you must be root or in the sudoers group:

sudo wall -n "Welcome to itslinuxfoss.com"

In the above example,

  • The “-n” flag tells the wall command not to print the banner.
  • It also displays the message to the sender that confirms the successful execution of the command.

Read: How to Add Users in the sudoers Group.

The user to whom the message was sent, will see it as:

Example 4: Send Broadcast Message With a Timeout Using the wall Command in Linux

The “-t” or “–timeout” flag/option of the wall command in Linux allows you to specify a timer after which the message will be discarded. The visual representation is as follows:

wall -t 30 "This message will be discarded in 30 seconds"

In the above example, the timer is set to 30 seconds before the message will be discarded using the “-t” flag/option.

The following message will be received by the remotely connected system:

Note: The message will be there even after 30 seconds, but the terminal’s control will be granted to the user. To instantly gain control over the terminal, press the “CTRL/Control + C” keys.

Example 5: Send Broadcast Message From a Specified File via the wall Command in Linux

To send a message from a file using the wall command of Linux, use the following syntax and replace “Messagefile” with your file’s name or provide the full path to it:

wall < Messagefile

In the above command, the “<” redirects the contents of the file to the remote system, and here’s how the message will be displayed:

The above broadcast message will be received (on the terminal)) by all the connected users.

Best Alternative of the wall Command

The wall command provides all the basic features for sending broadcast messages to the connected users. Here is the write command that we consider the best alternative to it because you can send messages to specific users instead of all connected users. 

The write Command

The write command is a basic message-sending utility for Linux. It allows you to send the message to a specific user and not to all the connected users like the wall command. The write command requires a connection to the remote system via the SSH. Once the systems are connected, use the write command like below, type the message, and hit the “Enter” button to send it:

write itslinuxfoss

The remote user’s terminal will display the following message on its screen:

That’s all for the wall command in Linux.

Final Words

The wall command in Linux is the best command-line utility for sending broadcast messages to all the connected users. It requires an SSH connection to be made first. The wall command comes with a few flags like “-t” to specify the timer before the message is discarded and the terminal’s control is given back to the user. More flags of the wall command are explained in this guide using examples.