The utilities discussed in this section exchange messages and files with other users either interactively or through email. They perform functions similar to iChat and Mail.
write: Sends a Message
The write utility sends a message to another user who is logged in. When you and another user use write to send messages to each other, you establish two-way communication. Initially a write command (Figure 3-14) displays a banner on the other user's terminal, saying that you are about to send a message.
Figure 3-14. The write utility I
$ write max Hi Max, are you there? o
The syntax of a write command line is
write username [terminal]
The username is the username of the user you want to communicate with. The terminal is an optional device name that is useful if the user is logged in more than once. You can display the usernames and device names of all users who are logged in on the local system by using who, w, or finger.
To establish two-way communication with another user, you and the other user must each execute write, specifying the other's login name as the username. The write utility then copies text, line by line, from one keyboard/display to the other (Figure 3-15). Sometimes it helps to establish a convention, such as typing o (for "over") when you are ready for the other person to type and typing oo (for "over and out") when you are ready to end the conversation. When you want to stop communicating with the other user, press CONTROL-D at the beginning of a line. Pressing CONTROL-D tells write to quit, displays EOF (end of file) on the other user's terminal, and returns you to the shell. The other user must do the same.
Figure 3-15. The write utility II
$ write max Hi Max are you there? o Message from firstname.lastname@example.org on ttyp3 at 16:23 ... Yes Zach, I'm here. o
If the Message from ... banner appears on your screen and obscures something you are working on, press CONTROL-L or CONTROL-R to refresh the screen and remove the banner. Then you can clean up, exit from your work, and respond to the person who is writing to you. You just have to remember who is writing to you, because the banner will no longer appear on the screen.
A user logged in on the graphical console is listed as logged in on the console terminal and cannot receive messages from write. However, a user on a terminal, including a Terminal window, can receive messages from write; terminals typically have device names such as ttyp3.
mesg: Denies or Accepts Messages
Give the following command when you do not wish to receive messages from another user:
$ mesg n
If Zach had given this command before Max tried to send him a message, Max would have seen the following message:
$ write zach write: zach has messages disabled
You can allow messages again by entering mesg y. Give the command mesg by itself to display is y (for "yes, messages are allowed") or is n (for "no, messages are not allowed").