Linux is an outstanding solution for your data center. It's incredibly flexible, stable, secure, and reliable. In fact, there's very little the open source platform can't do. That means you might have users logging into any number of your Linux servers for development purposes, testing, usage, etc. But what happens when you want to send all of those logged in users a message without having to blast a company email or place numerous phone calls? Since this is Linux, it's not only possible, it's also very easy.
I'm going to show you how to do this, however it must be noted there is one caveat—you can only send messages to all users who are logged into a terminal window. Although there are plenty of tools to send messages to a desktop, they don't allow widespread sending, or even sending to specific users, due to security issues. Because of this, you are limited to sending messages via the terminal window. Of course, the likelihood you'll have users logged into a graphical environment on your data center servers is next to /dev/null so the terminal is a fine solution.
I'm going to show you how to send a message to a specific user, and then to all users. There will be no need to install any software, as your Linux distribution will include everything you need. With that said, let's send a message.
Messages to specific user
The first thing you need to do is log into the server in question via SSH. Once logged in, you'll need to know is who is logged in. To find out what users are logged in, issue the command who. Anyone who is logged in will be displayed, along with the IP address of their originating machine—Figure A.
Let's say we need to tell Olivia the server is going to be rebooted in one hour. That should give her plenty of time to save her work and log out. To do this, we'll use the write command which sends the message, and the echo command to more easily compose the message. To send that message to user olivia, the command would be:
echo "This server is going to be rebooted in 1 hour!" | write olivia
Olivia will see the warning (Figure B) and can then hit Enter on her keyboard to dismiss the message.
Olivia can also reply with a command like:
echo "Understood" | write jack
User jack would then receive the message (Figure C).
Sending a message to all users
Say you have a large amount of users logged in, and you don't want to have to send them individual messages. To blast a global message to the system that will be reached by all logged in users, you could issue the command:
wall "System will be rebooting in one hour!"
This will display the same message to all logged in users (Figure D).
NOTE: Any user can take advantage of either the write or wall commands. You don't have to have sudo privileges or be root.
An easy solution for system-wide communication
Outside of running through your company and shouting out your message to all logged in users, you'd be hard-pressed to find a more efficient way to communicate your missives to users that are logged into your Linux servers. This is a great tool to ensure users are in the know of what's going on with your Linux data center servers.
- How to install Kloxo-Mr hosting control panel on CentOS (TechRepublic)
- How to install and use the smem memory reporting tool in Linux (TechRepublic)
- How to use syslog-ng to collect logs from remote Linux machines (TechRepublic)
- How to install and use Dockstation for easy container builds (TechRepublic)
- How to install the Prometheus monitoring system on Ubuntu 16.04 (TechRepublic)
- Cisco adds analytics services to its intent-based networking efforts (ZDNet)
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.