Linux Command Directory
This directory of Linux commands is from Linux in a Nutshell, 5th Edition.
Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.
mail [options] [users]
Read mail or send mail to other users. The mail utility allows you to compose, send, receive, forward, and reply to mail. mail has two main modes: compose mode, in which you create a message, and command mode, in which you manage your mail.
While mail is a powerful utility, it can be tricky for a novice user. It is most commonly seen nowadays in scripts. Most Linux distributions include several utilities that are richer in features and much easier to use: mailers built into browsers such as Mozilla and Firefox, graphical mail programs distributed with GNOME (Evolution) and KDE (Kmail), and the terminal-based, full-screen utilities pine and elm. The GNU Emacs editor can also send and receive mail.
This section presents mail commands, options, and configuration options. To get you started, here are two of the most basic commands.
To enter interactive mail-reading mode, type:
To begin writing a message to user, type:
Enter the text of the message, one line at a time, pressing Enter at the end of each line. To end the message, enter a single period (.) in the first column of a new line and press Enter.
You can also provide much of the information on the command line, as shown in the following example:
mail james -s "System Log" </var/log/messages
This command sends a message to the user james, with a subject line of System Log, and the text of the message read from the system logfile,
Set blind-carbon-copy field to comma-separated list.
Set carbon-copy field to comma-separated list.
Print debugging information.
Process contents of file instead of /var/spool/mail/$user. If file is omitted, process mbox in the user's home directory.
Do not respond to tty interrupt signals.
Run interactively even if the input is not from a terminal.
Do not consult /etc/mail.rc when starting up.
When printing a mail message or entering a mail folder, do not display message headers.
Read mail in POP mode.
Set subject to subject. Use quotes around subjects that contain spaces.
Process contents of /var/spool/mail/$user for the specified user.
Verbose; print information about mail delivery to standard output.
Disable POP mode.
Execute a shell escape from compose mode and run the specified command.
List compose-mode escapes.
Add names to or edit the Bcc: header.
Add names to or edit the Cc: header.
Read in the dead.letter file.
Invoke text editor.
Insert messages into message being composed.
Similar to ~f, but include message headers.
Add to or change all headers interactively.
Similar to ~f, but indent with a tab.
Similar to ~m, but include message headers.
Print message header fields and message being sent.
Abort current message composition.
Include file in current message.
Change Subject: header to string.
Add names to or edit the To: list.
Invoke editor specified with the VISUAL environment variable.
Pipe message through command.
Insert string in text of message, prefaced by a single tilde (~). If string contains a ~, it must be escaped with a \.
List summary of commands (help screen).
Execute a shell command.
Print numth previous message; defaults to immediately previous.
Print or create alias lists.
Specify remote accounts on remote machines that are yours. Tell mail not to reply to them.
cd to home or specified directory.
Similar to save, but do not mark message for deletion.
Delete current message and display next one.
Exit mail without updating folder or user's system mailbox.
Read messages saved in a file. If no file is specified, display the name of the current file. In addition to filenames, the following are allowed:
user's system mailbox
File in folder directory.
Print headers for messages.
List message headers at current prompt.
Move forward one window of headers.
Move back one window of headers.
Same as ?.
Hold messages in system mailbox.
Append list of fields to ignored fields. With no arguments, list currently ignored fields.
Compose message to user.
Move specified messages to mbox on exiting (the default).
Type next message or next message that matches argument.
Synonym for hold.
Display each message in list.
Similar to print, but include header fields.
Exit mail and update folder.
Send mail to all on distribution list.
Send mail to author only.
Same as reply.
Always include this list of header fields when printing messages. With no arguments, list retained fields.
Save message to folder.
Remove ignored fields when saving.
Override saveignore to retain specified fields.
Set or print mail options.
Enter a new shell.
Print size of each specified message.
Read commands from specified file.
Print first few lines of each specified message.
Same as print.
Same as Print.
Discard previously defined aliases.
Restore deleted message.
Mark specified messages as unread.
Unset mail options.
Edit message with editor specified by the VISUAL environment variable.
Write message, without headers, to file.
Same as exit.
Move mail's attention to next windowful of text. Use z- to move it back.
These options are set inside the user's
Append (do not prepend) messages to mbox.
Prompt for subject.
Prompt for blind-carbon-copy recipients.
Prompt for carbon-copy recipients.
Print next message after a delete.
Use the default pager to display a message of more than num lines. Defaults to the height of the terminal screen.
Same as -d on command line.
Interpret a solitary
.as an EOF.
Specify escape character to use instead of a tilde (~).
Define directory to hold mail folders.
Keep message in system mailbox upon quitting.
Ignore interrupt signals from terminal. Print them as @.
Do not treat ^D as an EOF.
Use the specified string with ~m as the prefix for indented messages.
Do not remove sender from groups when mailing to them.
Same as -N on command line.
Do not save aborted letters to dead.letter.
Switch roles of Reply and reply.
Do not print version at startup.
Use file as the path to record outgoing mail. If not set, outgoing mail is not saved.
When given the specifier /x:y, expand all messages that contain the string y in the x header field.
Print num lines of message with the top command. Default value is 5.
Same as -v on command line.