How to Use the wall Command on Linux

Configurare noua (How To)

Situatie

Need to get a quick message out to all logged-in users? Linux’s wall command is punchier than email and auto-targets the logged-in users. It broadcasts a message to everyone using a terminal on a system.

Solutie

The wall Command

If you need to get a message out—fast—to the logged-in users of your computer, how do you do it? Email doesn’t satisfy the requirements. You don’t know when the email will be read. If you need people to know something right now, that doesn’t cut it. And anyway, you don’t want to clog up the inboxes of logged-out users who don’t need to see the message.

Without exerting a bit of extra effort and wasting some time, you’re not going to know who is logged in and from where. Your system could be located in Aberdeen, Washington but you might have remote users logged in from Aberdeen, Scotland. So how can you target a message specifically at the logged-in users?

Linux and other Unix-like operating systems give you a simple way to do this. The wallcommand is like a forceful telegram. It will deliver a message to all terminal users, and it dumps the message right under their nose. The users can’t miss it, and you know they’ve got it. You don’t need them to choose to open an application to see if they have a message waiting.

The delivery is as subtle as a custard pie in the face.

Sending A Message

The test machine that this article was researched on was installed with Fedora Linux, but the wall command will behave precisely the same on other distributions.

The one difference you might encounter is some Linux distributions require you to use sudoon the option for sending a message from a text file, while other distributions require you always to use sudo with wall all the time. That’s actually a difference between Linux distributions, not a difference to the operation of the wall command itself.

To send a message to all users, type wall, a space, then the message you wish to send. With Fedora Linux, you must use sudo.

sudo wall Main printer offline until further notice.

Your message will be sent out to all users who have a terminal window open.

Local users RIa and Tom receive the message, as does remote user Dick, who happens to be working on a computer running Ubuntu.

They all get the message at the same time, and you’re not left wondering whether they’ve seen it.

Sending a Message From a File

You can prepare your message in a text file and store it ready to send. If you have a repeating cycle of messages that need to be sent, you can create a library of pre-packed messages so that you don’t need to re-type them again and again.

The message in the text file message.txt has been displayed to the terminal window with the cat command to make sure it is the one we want to send.

The message is then sent by passing the name of the text file to the wall command as a command line parameter:

cat message.txt
sudo wall message.txt

As before, local users Ria and Tom (and everyone else that is logged in with an open terminal window), and remote user Dick receive the message.

Messaging Etiquette

Because the wall command will push the message out to all terminal users no matter what, it can be a jarring experience to receive one. Use of the wall command should be kept to a minimum and only used where there is a genuine need. Otherwise, it will rapidly become very grating.

wall message will stamp over whatever else is on the user’s terminal. It doesn’t actually overwrite anything–it won’t change the text it has landed on top of—but it will obscure it. And that can be alarming for a user that doesn’t know this.

Imagine one of our local users is editing an important file in Vi just as the wall message is sent.

The message arrives right in the middle of her file.

All our user needs do to restore the correct view of the file is to page up and down a little way through the file.

It’s easy enough to restore the display to a state where work can continue, and blood pressure can recede, but too many interruptions of that sort are going to leave you with a very riled set of users.

So, as handy as wall is, use it in considered moderation.

What About Graphical Desktop Users?

The wall command reaches everyone logged in with a terminal open, but it won’t reach anyone who’s using a graphical desktop environment without a terminal window open.

If someone is using a graphical desktop and has a terminal window open, they’ll see it in the terminal window—but that’s it. Don’t count on wall to reach anyone outside of the terminal.

Subtle it isn’t, but you can’t deny it does get the message across—in a traditional terminal environment, that is.

Tip solutie

Permanent

Voteaza

(4 din 7 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?