Home   Profile   Fun
#151 Linux  07.01.2008

How to send a message to other logged in users


If you are root you can easily get into contact with all logged in users on a system. Some examples follow which explain how to send a message to all users, or just print information about all logged in users.

First become root if you are not already. Then print information about the other users with the w command. This will print their names along with their virtual terminal, login time and their current process.
w

If you want to find out your own virtual terminal just type
tty


Now, to broadcast a short message to all logged in users the wall command can be used:
echo "a message" | wall

For a longer text it might be better to just type wall and press enter, write the message and send it with ctrl-d:
wall
This is a message
with several lines
[ctrl-d]

Note, that a user can prevent the display of messages from other (non-root) users with
mesg n
or reactivate it with
mesg y