Red Hat Linux: Using Communication Tools Under LinuxThe communication tools discussed in this chapter include the following:
This chapter discusses all of these communications tools in detail and gives
you the basics of how to use them in Linux. With practice, you will soon begin
to use these tools effectively. The write command is a communication tool that enables a user to interact
directly with other users. If you want to ask your friend a simple question or
ask her out to lunch, and you know that she is logged in, write is the tool to
use. Unlike e-mail, which is discussed later, write pastes your message directly
on the recipient's terminal. The recipient does not have to take any steps to
receive it. To use the write command, your terminal and that of the other user should
have write permission. Having these permissions enables you to write messages on
each other's terminals. To look at the terminal settings, you need to know which
terminal you are on. To find your terminal number, use the tty command as shown
here: mpsi:~$ tty The preceding code sample shows that I am on /dev/tty2. Your output may be
different, depending on which terminal you happen to be on. The output of the ls
command shows that others have write permission available on your terminal. You
can confirm this by using the mesg command as shown here: mpsi:~$ The outcome of the mesg command shows that the terminal enables messages to
be written to it. You can toggle the terminal settings on and off with the
following command: mpsi:~$ mesg n The preceding segment turned the mesg off. Now you can't be disturbed by any
other user. (You may miss out on lunch dates, though.) A Description of the write Command The write command enables you to write an actual message on the other
terminal online. You have to issue the write command with the login ID of the
user with whom you want to communicate. The write command informs the user at
the other end that there is a message from another user. write pastes that
message onto the other user's terminal if their terminal's write permissions are
set. Even if they are in the middle of an edit session, write overwrites
whatever is on the screen. The edit session contents are not corrupted; you can
restore the original screen on most editors with Ctrl-L. write is mostly used
for one-way communication, but you can have an actual conversation as well.
A Sample write Session Because you want your friend to be able to write to your tty as well, always
begin by checking the status of the mesg command: mpsi:~$ Let's see whether your friend Calvin is logged in. You can do this by using
the who command and piping it to the grep program to search for Calvin, because
you don't want the entire list of users to scroll down your terminal. mpsi:~$ who | grep calvin
Now let's see whether he wants to be disturbed: mpsi:~$ ls -al /dev/tty2 This excerpt shows you that Calvin is indeed logged in. Now let's see whether
he is interested in communicating with a write session: mpsi:~$ write calvin Calvin sees the following on his screen: mpsi:~$ Now you have to wait for Calvin's response to the request. He responds by
typing the following on his terminal if he is interested in communicating with
you: mpsi:~$ write laurel The following string appears on your terminal: Message from calvin@mpsi on tty2 at 15:36 ... You can answer Calvin by initiating another write session from your end and
typing your message. You have to press Enter at the end of each line for it to
be displayed at the other terminal. To simplify communications, you can type
over at the logical end of your sentence. Calvin should do likewise. write Etiquette If you are waiting for the other party to respond to your write request, it
is polite to let him reply while you wait. Only after he has accepted your
invitation should the conversation begin. Also, let the called party have the
first chance to reply by typing hello or any other salutation. Avoid typing
until the other party stops or signals you to begin with an end-of-message word,
such as over. Remember, only one person can speak at a time on this channel. The talk Communication Tool The write tool was nice for communicating one at a time. However, Linux
enables you to type simultaneously with the talk tool. talk is an interactive communication tool that enables you to have an actual
conversation in real-time mode with another user. You can actually see the
conversation being typed as the other user is typing it. For talk to work, the
other user has to be logged in, just as in write. talk can be very annoying and disturbing if someone wants to be pesky. If you
don't want to be disturbed, just turn talk off by entering mesg n at the prompt.
A Sample talk Session You can talk to somebody by typing talk followed by the user's login ID. To
see if the user is logged in, you can use the who command just like you did for
write. Let's try to talk to Calvin: The computer responds with The user on the other end sees the following message even if he is in the
middle of an edit session. The system beeps and displays the following message
on the terminal: Message from Talk_Daemon@mpsi at 13:08 ... To respond to this, type the command shown in the respond with message shown
here. If your friend does not respond, the talk daemon persistently bothers him
with the preceding message every 30 seconds. At your terminal, you see the following messages: [Ringing your party again] Occasionally you will see the following message: What happened? Your friend at the other end does not want to talk or be
disturbed. After several of your interruptions, he has decided to turn his mesg
off. That is why you got the message that your party is refusing messages. Now let's look at a nicer scenario, when someone wants to talk to you. He has
to respond with the following command: talk laurel. Then your terminal displays the following screen: [Connection Established] The screen is divided horizontally with a dotted line, and you can type your
message on the top half of the screen. This appears verbatim on the other
terminal at the bottom half of the screen. You can type your messages, and the
other user can type his, simultaneously. The connection can be closed by entering Ctrl-C. The following line appears
on the screen: [Connection closing.Exiting] You should now be back at your shell's command prompt. talk Etiquette The same etiquette applies to talk as in write. Always use lowercase letters,
because CAPS LOCK conversations are considered loud and rude. Always finish your
sentence by typing over. If you initiated the talk session, wait for the other
party to respond with the hello first. To prevent both of you from typing at the
same time, always read your message, wait for the over, type your own message,
and then terminate it with over. Electronic Mail Electronic mail has taken the world by storm. E-mail, short for electronic
mail, is a method of sending a message from a user on one computer to one or
several recipients on another computer. E-mail provides fast and efficient
transportation of data and documents. This mode of communication also eliminates
the need to play telephone tag or to wait for a convenient or appropriate time
to call someone. For someone with Internet access, e-mail provides the means to
communicate with friends around the world. E-mail originates in the form of a file on your computer created by a
Mail User Agent (MUA). E-mail is then submitted to a mail router such as
sendmail, after which it is handed over to a Mail Transporter Agent (MTA).
E-mail is then appended to a mailbox. The MTA delivers it to the final delivery
agent by traversing one or more hosts. The MUA is used to read and send mail. The MUA is the user interface for the
mail system. Mail can be composed by using simple MUAs such as mail or mailx, or
sophisticated mail user agents such as elm or pine. Understanding the Mail Message A mail message includes two parts: a mail header and the text body. Date: Fri, 6 Jan 1995 13:27:00 -0600 Date specifies the date and time the message is sent. From specifies both the sender's name in quotes and the address, which
includes the login ID and the address of their machine, hobbes.com. The mail header is followed by the body of the mail message. Here you type
the message as text. The mail message is terminated by typing a period (.) as
the first character on the last line. The mail handler responds with EOT, for
End Of Text. This is the standard procedure for Berkeley mail; other mail
handlers have their own way of ending message text entry. Types of Mail User Agents There are several types of mail user agents, some of which are listed here. A
variety of different programs can be used for reading the mail. The two most
common programs are mail and Mail (also called mailx). Because of the similarity
of their names, Mail is also called capmail or Berkeley Mail. Berkeley Mail is
far superior to mail because it is much easier to use. This section covers the following types of mail user agents:
Using elm elm stands for electronic mail and provides a full-screen interface mail
program with a good help feature. elm is a pleasure to use when compared with
Berkeley Mail because of its simplicity of use and functionality. The screen is cleared, and the code shown in the following screen is
displayed. The top line on the screen is the mailbox and the number of messages it has
in it. You may also see elm's version number. This is followed by a list of all
the messages in the mailbox, the date the messages were sent, the sender's name,
and the subject of the message. The current message is indicated by an arrow or inverse video. One nice feature of elm is that it displays the sender's name instead of the
login ID as Berkeley Mail does. The bottom part of the screen lists the options available. At this point, you
can reply to the message, delete or undelete a message, or forward the mail by
entering the appropriate command. You can go up and down the message list by
using k and j, just as in the vi editor.
Let's try to send mail using elm. To send mail, press m on the main screen. The header screen appears. elm
prompts you to enter the name(s) of the recipient(s) of the mail. Enter calvin
and root as recipients. Calvin is the primary recipient, and a copy of this
message is sent to root as well. elm then prompts for a subject. After entering the subject heading, elm puts
you in the vi editor to enter the body of the mail message. After you are
finished typing, use the vi command :wq to save and quit the vi editor. You can
now send the message by pressing s. You can also forward mail to others on the system with the f command or reply
to a message with the r command. To quit elm, type q at the main screen. If elm is available on your system, try to use it. elm is very convenient and
simple and can greatly improve your electronic mail interaction. Using Pine Pine, a trademark of the University of Washington, stands for Program for
Internet News and E-mail. Pine offers the capability to send local and remote
messages using a simple user interface as well as the capability to send
documents and graphics. You invoke Pine by entering pine on the command line. The screen shown here
should appear. $ pine Pine is very easy to use, because it provides a full-screen interface with
the up and down cursor controls. Simply select the item you want by using the
arrow keys and press Enter at the selected line. Let's send a message using Pine. Take the cursor to the Compose Message line
and press Enter. The screen shown here appears. PINE 3.91 COMPOSE MESSAGE Folder: INBOX 1 Message Pine takes you line-by-line through the mail header and the mail message.
Press Ctrl-X to end the message as well as send it to the recipient. Just walk
through all the options to get a feel for this mail system. The last two lines on the screen tell you what commands are available for the
current situation. Usually there are more commands than can be shown on two
lines, so use the O key to see what other commands are available. The O is
optional; you don't have to be able to see a command before you use it. Pine creates a default configuration file, .pinerc, in your home directory.
You can edit this file to select various options. Pine also creates a mail
subdirectory for your saved-message folders. Type ? from the Main Menu for more
help. This section is about mailx, another common mail program for Linux. This
section covers the basics of mailx. mailx has many options and features, most of
which are listed in its man pages. Discussing all these features would require a
book in itself. Let's see how to receive and send mail using mailx. Receiving Mail Suppose someone has sent you a mail message. How would you know about it? The
Mail system deals with this by displaying a message when you log in. A sample
login session is shown in the following screen. Welcome to Linux 1.2.13. To read the mail message, invoke the Mail handler by typing mail at the
prompt. You will see the output shown in the following screen. mpsi:~$ mail In this example, the user Calvin has received a mail message from another
user, Laurel. This message is the first message in the message queue and is
declared as new, which means it has not been read yet. The message queue has an
>N, indicating that it is a new message, followed by a message number (1), the
sender's login ID (laurel@hobbes.com), the day of the week, the date and time
the message was sent, and the subject of the message. The ampersand (&) is the mail system prompt. You can now read the message by
typing the message number at this prompt. & 1 Mail Options All the available options in the Mail system can be listed by typing a ?
after the &. The listed options are shown in Listing 14.1. Listing 14.1. Mail options. & ? Replying to a Message Suppose you have three mail messages from different users and you want to
reply to the one sent by Jeremy. Just invoke mail as before, as shown in Listing
14.2. Listing 14.2. Three received messages.
mpsi:~$ mail The U in front of the second message specifies that the message is still
unread. You can read the message by typing the message number. & 2 You can reply to the message by typing r. & r The Mail daemon automatically sets up the header in the reply mode, so all
you have to do is type the text. Sending and Forwarding Mail Sending and forwarding mail can be done with the s and f commands,
respectively. The procedures for creating the header and text of the message are
similar to that of replying to a message. The ~/signature file is appended to every mail message you send. You should
place text in here that you want to send with every message. Some examples are
your phone number or an alternative e-mail address (your recipient might not be
able to reply to certain hosts). Mail etiquette requires that you keep you
signature files short—four lines or less. Most recipients do not like to see
pages of information about you in every mail message. Using news Using news is perhaps the best way of getting into what is probably the
world's best online forum: the Usenet news service. There are literally
thousands of giant bulletin boards for you to select topics from and post
messages to. The number of subjects available can be quite overwhelming at
times, since there are more than 13,000 newsgroup topics to choose from. (A
newsgroup is one of the bulletin boards.) Newsgroups offer the best example of
free speech and a forum for discussing just about any topic imaginable. Topics range from the serious to the absurd. In the serious category you can
talk about computer communications (comp.dcom.telecom), astronomy (sci.astro),
and so forth. In the absurd corner you have alt.tasteless,
alt.barney.dinosaur.die.die.die, and alt.fan.oj-simpson.drive.faster. Usenet was started at Duke University in 1979 by two students, Tom Truscott
and Jim Ellis, as an experiment to connect two computers between Duke and the
University of North Carolina. From these two news sites in 1980, the number of
news sites has grown to hundreds of thousands of sites in the 1990s, with
millions of subscribers worldwide. There are several news readers for Linux. I will cover two: nn and tin. nn The nn news reader stands for Net News. When you use nn, you decide which of
the many news groups you are interested in. You unsubscribe those that do not
interest you any more. nn lets you read all articles in each of the groups you
subscribe to, using a menu-based article selection prior to reading the articles
in the newsgroup. When you enter a newsgroup in nn, you are presented with a screen that lists
the most recent unread articles. Each item on this list contains at least the
sender and subject. You are now in selection mode. You can select using the A
through Z and 0 through 9 keys. When you select an article, it is displayed in a
highlight color. If you press the spacebar, you go into read mode. In read mode, nn presents you with each article. Press the spacebar to get to
the next page of each article. If you are at the end of an article, the spacebar
takes you to the next article. When you have read all the selected articles in the current group, pressing
the spacebar takes you to the next group. Here are some of the other commands in nn:
The nn man pages provide about 600 lines of very detailed information about
all the options and commands available to you. You do not have to use all of
them—just use as many as necessary to customize your own environment. tin tin is a screen-oriented Net News reader. It can read news locally (/var/spool/news)
or remotely (rtin or tin -r option) via an NNTP (Network News Transport
Protocol) server. tin is based on the tass newsreader, which was developed by
Rich Skrenta in March 1991. tass was itself heavily influenced by NOTES, which
was developed at the University of Illinois by Ray Essick and Rob Kolstad in
1982. The most relevant author to date is Iain Lea (iain.lea@erlm.siemens.de).
Check the long list of contributors in the man pages.
On startup, tin shows a list of the newsgroups found in $HOME/.newsrc. An
arrow (->) or highlighted bar points to the first newsgroup. Move to a group by
using the terminal arrow keys or j and k. Use Page Up and Page Down or Ctrl-U
and Ctrl-D to page up and down. Select a newsgroup to read from by pressing
Enter. The Tab key advances to the next newsgroup that has unread articles and
enters it. To start and run tin, export NNTPSERVER to the address of your remote news
server. Use the command Then run tin with the -r option to connect to this remote server. A sample tin session is shown in Listing 14.3. It shows two newsgroups that I
have subscribed to: alt.humor and tx.jobs. When you select a message to read from and press either the right arrow or
Enter key, you are shown the message itself, as shown in Listing 14.4. Listing 14.3. A sample tin session. Group Selection (news.neosoft.com 2) h=help Listing 14.4. Another sample tin session.
tx.jobs (368T 401A 0K 0H R) h=help In Listing 14.4, you see a list of subject headers and their index numbers.
The + sign indicates that you have not read this message. For example, the SONET
job for Dallas, Texas, has an index of 184 and is unread. To read this message,
use the arrow keys to move to it, and then press Enter. Command-Line Options tin has several command-line options, some of which are listed in Table 14.2.
To add a new group, type ggroupname. For example, gmisc.invest adds the
newsgroup misc.invest. tin offers an emacs-style editing facility for entering messages. The command
strings include a history of commands to enable reuse of previous commands. The
man pages for tin list all the commands available to you for editing, deleting,
and removing messages. tin uses the following important environment variables:
tin can pretty much be navigated by using the four arrow keys. The left arrow key goes up a level; the right arrow key goes down a level; the up arrow key goes up a line or page; and the down arrow key goes down a line or page. Most prompts within tin can be aborted by pressing Esc. Using FTP File transfer protocol (FTP) is a method of transferring files from one
computer to another. FTP provides the capability of transferring files to and
from a remote network site as well as means for sharing public files. In this
section you go through a sample FTP session and follow the steps for finding and
getting software from a remote site. ftp is the user interface to the ARPANET standard FTP. The ftp service is the
interface to the file transfer protocol. It lets a user connect to another site
and send and receive files. In this section you will try to get a file from the address tsx-11.mit.edu by
logging in as anonymous. This anonymous use of FTP is very convenient and
provides access to innumerable servers, providing a wealth of information.
Publicly accessible FTP servers are called anonymous FTP servers. Anonymous FTP Anonymous FTP enables users to access remote sites without having an
authorized user ID and password. Generally the login ID is anonymous and the
password is guest. Most current systems require your e-mail address as the
password instead of guest.
The client host with which ftp is to communicate may be specified on the
command line. If this is done, ftp immediately attempts to establish a
connection to an FTP server on that host. Otherwise, ftp enters its command
interpreter and awaits instructions from the user. When ftp is awaiting commands
from the user, the prompt ftp> is provided to the user. Enter ftp at the prompt,
along with the site address: A hostname can be either a hostname or an Internet address. For example, you
can use the following Internet address: If your system connects to the MIT server, the text shown in Listing 14.5
appears. Listing 14.5. An ftp session. 220 tsx-11 FTP server (Version wu-2.4(3) Mon Jun 5 16:40:22 EDT 1995) ready. The first line confirms that the connection is established. Line 220
indicates that the FTP server is ready. The system then prompts for a name,
which is anonymous in this case, and a password. The password is not echoed, so
any typing mistakes you make are not apparent. You are then connected to the
remote FTP server, which awaits your commands. ftp Commands The ftp service enables the user to execute several commands. Some of the
local commands are listed in Table 14.3.
Some of the options that may be specified at the command line are listed as
follows:
Some ftp commands share the same name as Linux commands but perform a
different function. For example, the ls command in ftp behaves like the ls-al
command in Linux. To illustrate how this works, let's look at the directory
listing command on a remote server:
ftp> As you can see, you did not have to type -al. You get the long listing from
the ls command. To abort a file transfer, use the terminal interrupt key (usually Ctrl-C).
Sending transfers are immediately halted. Receiving transfers are halted by
sending an ftp ABOR command to the remote server and discarding any further data
received. The ftp specification specifies many parameters that may affect a file
transfer. The type may be ascii, image (binary), or ebcdic. telnet The telnet command is used to communicate with another host using the TELNET
protocol. If telnet is invoked without the host argument, it enters command
mode, indicated by its prompt, telnet>. Normally you would use where hostname is the host you want to connect to and port indicates a port
number (an application's address). If a number is not specified, the default
telnet port is used. telnet can log you in either one of two modes: character-by-character or
line-by-line. In character-by-character mode, most text typed is immediately
sent to the remote host for processing. In line-by-line mode, all text is echoed
locally, and only completed lines are sent to the remote host. While connected to a remote host, you can enter the telnet command mode by
typing the telnet escape character, Ctrl-]. When in command mode, the normal
terminal editing conventions are available. The following commands are available under the command mode:
Check the man pages for a list of long, detailed options for telnet. Let's use telnet to do an Archie session. An Archie server is helpful for
searching for files by giving a keyword in a title. See Listing 14.6. Listing 14.6. Logging in via telnet. $ telnet archie.internic.net The archie> prompt is asking you for input. Let's look at some of the help
information available for Archie. Type help at the archie> prompt. See Listing
14.7 for a sample output. Listing 14.7. Help for Archie. archie >help Now let's try to find a file on HylaFAX. Use the command find, as shown in
Listing 14.8. The sub string indicates that you are searching for the word in
the entire filename and are not looking for an exact match. Listing 14.8. Finding by keyword. archie> find hylafax The results of the match are shown in Listing 14.9. You can scroll up and
down with the k and j keys. The spacebar scrolls one page. The Enter key scrolls
down one line at a time. You can stop the listing with the q key. Listing 14.9. The output of the Archie command.
Host freebsd.cdrom.com (192.153.46.2) After you are finished with Archie, you can log off the server. This closes
the telnet connection. You can get your HylaFAX files via FTP from these sites.
|