You can use any text editor to edit the /etc/aliases file. The previous example shows the method for using the vi editor to edit the file. If you are not already familiar with vi, refer to Chapter 6, Using the vi Editor for instructions.
Note that the pound signs (#) you see within the /etc/aliases file have been placed there to comment out the text and sample aliases. The pound signs prevent the system from processing this information as actual aliases.
Do not place pound signs in front of aliases you add to this file, unless you intentionally want to disable an alias.
To send mail to people on a /etc/aliases alias, address the mail by using the name of the alias and your machine name. Suppose that you sent the following:
$ mail softball@texas Subject: Practice Today Let's meet at the diamond behind Building 4 after work tonight. Goodness knows we can use the practice for Saturday's game! Be there as early as you can. |
The recipients would see the following:
To: softball@texas Subject: Practice Today Let's meet at the diamond behind Building 4 after work tonight. Goodness knows we can use the practice for Saturday's game! Be there as early as you can. |
Notice that the To: line is not expanded.
Whenever you send mail by using a mail alias of this type, be sure to include the machine name of the machine on which it's located. If you set up a mail alias called riders on the machine freeway, then you should send your mail to riders@freeway.
Table 7-1 provides a summary comparison between mail aliases that are created in .mailrc and those that are created in /etc/aliases.
Table 7-1 Comparing Mail Aliases in .mailrc and /etc/aliases
| .mailrc | /etc/aliases |
---|---|---|
Must be root to modify? | no | yes |
Send message to: | alias | alias@machinename |
Recipients list seen by recipients? | yes | no |
Names separated by commas? | no | yes |
Names all on one line? | yes | no |
Others can use the mail alias? | no | yes |
For more detailed information on mail aliases, type man aliases or man addresses at the system prompt.
Tilde Commands
In the course of composing a message, you can use tilde commands to perform a variety of functions. Tilde commands usually consist of the tilde character (~) followed by a single character. The following table describes some of the more useful tilde characters. Some of these characters have already been introduced in this chapter.
Note - If you want to include a literal tilde character in a message, type two tildes in succession. Only one tilde is displayed.
Table 7-2 Tilde Commands (mailx)
Command | Description |
---|---|
Escapes to a shell command. | |
Simulates pressing Ctrl-D to mark end of file. | |
Lists a summary of tilde commands. | |
Adds user name(s) to the blind carbon copies (Bcc:) list. | |
Adds user name(s) to the carbon copies (Cc:) list. | |
Reads the contents of the dead.letter file into current message. | |
| Forwards the specified message. Valid only when you send a message while you read mail. |
Prompts for header lines: Subject, To, Cc, and Bcc. | |
| Inserts text from the specified message into the current message. Valid only when you send a message while you read mail. |
Prints to the screen the message that you are typing. | |
Simulates pressing Ctrl-C twice. If the body of the current message is not empty, the contents are saved to dead.letter. | |
Reads in the text from the specified file. | |
Changes the subject line to string. | |
Adds the specified name(s) to the To list. | |
Writes the current message without the header into the specified file. | |
Exits mailx. Similar to ~q except message is not saved in the dead.letter file. |
Getting Help: Other mailx Commands
mailx has two help commands that display lists of commands and functions. When in command mode, you can type ? at the mailx prompt (&) to see a list of commands used in that mode. Similarly, when in input mode (for example, when writing a message), you can use the equivalent command, ~? to view a list of tilde commands (also called "tilde escapes").
The man pages contain extensive information on mailx in more technical form. To see this entry, type the command:
$ man mailx |
For more information, refer to the man Pages(1): User Commands.