Main index

Introducing UNIX and Linux


Getting started

Overview
Using UNIX
      Usernames
      Logging in
Logging out
Commands
      Typing in commands
      Commands and options
Communication with other users
      Email
      Other communication facilities
Files
      The editor Vi
            Vi commands (command mode)
            Vi commands (colon mode)
      Other editors
Input and output
      Scripts
      Here-documents
      Pipes
      Making copies of input and output
      Pagers
Emergencies
Getting help
Summary
Exercises

Email

Although most people are familiar with email, through sophisticated mail software such as Microsoft's Outlook or Eudora, it is instructive to look at the basic facility available under UNIX. This does still have uses, for example if you require a shell program to send email without intervention from the user. The standard utility for sending email is Mailx. To make use of this, you need to know the username of the person you wish to send a message to. Type mailx followed by the username, and then type in the message terminated by ctrl-D on a line of its own. If option -s is given to mailx, the string following -s will be used to denote the subject of the message to the recipient. It is always good practice to give an email message a subject, and if the subject string contains spaces, then it must be enclosed in quotes. For example,

mailx -s "Programming Assignment" sam
Hello Sam.
Have you finished the assignment yet?

ctrl-D

will send a message to user sam. If you have a tilde (the symbol ~) as the first character on any line you type in, this will be interpreted by mailx as a management instruction. For instance, if you wish to edit a message half-way through typing it in, type ~v and you will then be editing it using a standard text editor (usually Vi). If you have a friend who is currently logged in, mail him or her a short message and ask them to mail you one. If not, mail one to yourself. In either case, the mail arrives almost instantaneously. In order to read mail that has been sent to you, just type mailx on its own. If you have mail that you have not read, mailx will display a brief list of messages awaiting you, with the date they were received, the name of the sender, and the subject (if specified by the sender). For instance,

mailx
>N  1 sam Wed Jul 27 15:28  16/465  Programming Assignment
 N  2 jo  Thu Jul 28 19:33  77/1220

In this example, you have two messages (each message is given a number), the first from user sam, the second from user jo. The mail from sam has subject Programming Assignment, is 16 lines long and contains 465 characters; that from jo was sent without a subject specified, is 77 lines long, and contains 1220 characters. While you are reading your mail, at any particular moment one message is current, and may be read, deleted, saved in a file, or edited. The > symbol indicates that message number 1 is the current message. The command p (print) will then display the current message on the screen. If you type ? a screenful of help messages will be displayed indicating the other commands you can give to Mailx. Note that this mail is simple text, and does not contain attachments, or HTML enhancements, which are now commonplace. Most UNIX systems are equipped with a collection of other (not POSIX) programs for electronic mail, Elm, Mail, Mush, Pine, and Xmail coming to mind. These utilities are similar to Mailx, but the sophistication and facilities vary. Check with your system administrator for the preferred mail programs on your system, and if they differ from Mailx for simple use. Most Web browsers also include commands to let you send mail.


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck