- [Instructor] Hi, and welcome
to the next video of the last section.
Sending Messages to User Terminals
In the previous video, we've learned about killing processes
and send or respond to signals.
A system administrator may need to send messages
to the terminal of every user or a specified user
on all machines over a network.
This video is a guide on how to perform this task.
Wall is a command that is used to write
messages on the terminals of all logged in users.
It can used to convey messages to all logged in users
on a server or multiple access machines.
Sending messages to all users
may not be useful at all times.
Terminals are treated as devices in a Linux system
and hence these open terminals will have
a corresponding device node file
at slash dev slash P-T-S.
Writing data to a specific device
will display messages on the corresponding terminal.
In order to broadcast a message
to all users and all logged in terminals, use
The message outline will show who sent the message,
which user and which host.
It is noteworthy that the message gets displayed
to the current terminal only
if the right message option is enabled.
In most, this right message enabled by default.
If the sender of the message is root,
then the message gets displayed on the screen
irrespective of whether the right option
is enabled or disabled by the user.
In order to enable right messages, use
In order to disable right messages, use
Let's write a script for sending messages
specifically to a given user's terminal.
Run the script as
The output will be as follows
Now the text command's terminal
will receive the message text.
Let's see how it works.
The dev P-T-S directory will contain
character devices corresponding to each
of the logged in terminals on the system.
We can find out who logged into which terminal
by looking at the owner of the device files
from the L-S minus L output.
This information is extracted by using awk
and then grep is used to extract
the lines corresponding to a specified user only.
The username is accepted as a first argument for the script
and stored as a variable username.
Lot of devices contains a list
of terminals for a given user.
Which is iterated using a for-loop,
slash dev, slash S-T-D in,
will contain standard input data
past to the current process, which is redirected
to the corresponding terminal T-T-Y devices.
Also, we've successfully learned
how to send messages to user terminals.
In the next video, we'll learn
how to gather system information.