How to message other users logged in to a Ubuntu/CentOS server?

Would you like to broadcast a message to other people logged in to the same Ubuntu or CentOS server you are connected to? Is it possible to write private messages to other users or send a message to all users logged in to a machine or server?

There are a few commands that you will find helpful in such cases. To find if more users are logged in to the system, you can run the who command to see all users logged in to the system.

How to message other users logged in to a Ubuntu/CentOS server?

The WALL command.

The wall command is useful if you want to write a message or a notification to all users logged in to the system. It can be reached by typing the command wall in the command line. Press enter, and then you can start to type the message you would like to broadcast. As you finish the message, click CTRL+D and the message will be sent to all users logged in to the system.

the wall command in ubuntu

In the left window, I am writing the actual message. I started by typing wall and pressing enter. Then I write the actual message and once finished, I click CTRL+D to send the message. The text is then broadcasted to all users logged in on the system, including to myself in the left window and a second user I have logged in to the system in the right wall.

How to limit the use of WALL to root or SUDO users?

Suppose you have a big company with lots of people. In that case, it might get annoying if people use the wall command to send entertaining messages and the latest news from the football world, Hollywood, and gossip about White Lotus and other TV series. Is there a way to limit the WALL command to root or users with SUDO rights? Run the following command, and you can only use the wall command if you are root or have SUDO privileges.

which wall (the outcome will show you the located of the script)
sudo chmod g-s /usr/bin/wall

This will make it impossible for normal users to run the command, meaning that only the root user or users in the sudoers group can run the command.

The WRITE command.

Would you like to send a message to one designated user? It can be done using the write command. Some users have disabled the ability to receive messages. How can you find out if you are accepting messages or not?

mesg

This command will show you whether you accept messages or not. You can change it with the command below if it is set to no.

mesg y

When everything is ready, you can run the following command.

write username

You will then be able to type messages. As soon as you click enter, the message is sent. You can write more messages after this, and close the conversation from your side by clicking CTRL+D.

If you are the other user and want to join the conversation, run the command write username on your device. You will then be able to write back in the conversation and chat until you click CTRL+D to leave the conversation.

write command in ubuntu

You can now chat with someone logged in to the same Ubuntu or CentOS server as yourself. You can also broadcast messages to other users logged in to the system.

Would you like to read more interesting articles about Ubuntu and CentOS? Would you like to know which is the best VPN for Linux Mint? You will find lots of articles here in our IP Address Guide.

Leave a Reply