*NIX chat

Well, no, not chat in the common/modern sense but did you know you can display which users are connected to the same system you’re logged on and send them messages?

First off, displaying users connected to the same system is, for sysadmins, a basic and quite an important monitoring command.

The syntax is extremely simple: “w“!

Example:

$ w
10:02:12 up 2 min,  2 users,  load average: 0.33, 0.18, 0.07
USER      TTY      FROM             LOGIN@   IDLE   JCPU   PCPU  WHAT
<userid1> pts/0    <src IP addr>    10:02    0.00s  4.83s  0.08s bash
<userid2> pts/1    <src IP addr>    10:02    0.00s  4.83s  0.08s w

Now, sending a message to <userid1> from <userid2> is as easy as:

echo "I'm about to disconnect you ;)" | write <userid1> pts/0

On <userid1>‘s console the following will be printed:

Message from <userid2>@<server> on pts/1 at 10:04 ...
I'm about to disconnect you ;)
EOF

Please notice that the TTY being used, pts/0 in the example, may differ from one OS to another.
For instance, on Mac OS X, it should be ttys00x.

The same is possible on Cisco routers by means of “send” command.

Leave a comment