Stupid UNIX Tricks: User-to-User Communication
Posted on November 5, 2008
Today and interesting post came across Slashdot: (Useful) Stupid Unix Tricks? The post points out other users that were unaware of the write command. This doesn’t surprise me, a lot of sysadmins likely don’t know about some of these tools… after all, the “write” command isn’t exactly self-evidently a tool to communicate with another user.
There are several tools that allow users to communicate with one another through the shell, we’ll talk about 3: wall, write, and talk, as well as its friend mesg.
Firstly, the wall command allows a sysadmin as root to message all users on the system. This is used by script such as “shutdown” or “reboot”, telling everyone to get off. Use is simple. Either give it standard input (ie: “banner GO AWAY | wall”) or running the command, entering your text including line breaks and then completing with ^D. Here is an example:
root@quadra ~$ wall System Maintaince Tonight! Please be aware that the system is going down in 20 mins. Please save your work and get off ASAP! Thank You - SysOps Team ^D
And here is what the users see:
bash-3.2$ Broadcast Message from root (pts/10) on quadra Wed Nov 5 15:14:58... System Maintaince Tonight! Please be aware that the system is going down in 20 mins. Please save your work and get off ASAP! Thank You - SysOps Team
Secondly, the write command sends a message directly to a single user. Anyone can use this command. This is an ancient form of in-band instant messaging that is commonly used by sysadmins to communicate, but has fallen out of use being replaced by out of band instant messaging like Jabber, AIM, etc.
To use write, specify the user, and optionally their pty (if they have multiple logins). Then type your message and hit ^D.
benr@quadra ~$ write tamr Hey, what are you doing editing /etc/user_attr???
The user see’s each line of text entered as you hit return, and finally an “EOT” when you ^D:
bash-3.2$ Message from benr on quadra (pts/6) [ Wed Nov 5 15:18:06 ] ... Hey, what are you doing editing /etc/user_attr??? bash-3.2$
The user can then respond in the same way. This can also be sped up by using pipes or redirection.
The third command is the real-time user communication tool, talk. I say real-time because you can see each character the other user enters… this has lead to many “d00, learn to type!” insult exchanges. In 1994 when my local ISP was just a SunOS system, many of us dialing in used talk as a form of pseudo-chat with other users.
The “talk” tool requires a daemon process. On a default full install of Solaris you’ll find it as a disabled service. To use it, simply enable via SMF:
root@quadra ~$ svcadm enable talk root@quadra ~$ svcs talk STATE STIME FMRI online 14:52:36 svc:/network/talk:default
Now, initiate a discussion using the form “talk user2”. The user will get a message informing them of the request and tell them how to respond, by recipricating user: “talk user1”. When established, a session looks like this:
Whats even more fun, is that you can actually talk to users on other systems! Very versital and fun to user. A GNU variant of “talk” is available thats even more powerful and interesting than the classic SysV version on Solaris, allowing you to shell out and demo things to users, etc.
The final command we’ll look at is mesg. This command takes the option y or n. It simply determins whether or not other people can but you using write and talk. This is the system equivalent of setting “away”.
benr@quadra ~$ mesg n benr@quadra ~$ mesg is n
The main reason for this is to avoid messages from annoying users or avoid getting a message while doing something sensitive. For instance, getting a “write” message while editing a file in VI will cause your screen to become a mess and potentially mess up your edits unless you refresh.
So go forth, have fun, and annoy your friends. Maybe next week I’ll try to convince you that blogs are still lame compared to the original finger.