oreilly.comSafari Books Online.Conferences.


Linux in a Nutshell

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.

Buy it now, or read it online 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:

mail user

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, /var/log/messages.

Command-line options

-b list

Set blind-carbon-copy field to comma-separated list.

-c list

Set carbon-copy field to comma-separated list.


Print debugging information.

-f [file]

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.

-s subject

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.

Compose-mode commands


Execute a shell escape from compose mode and run the specified command.


List compose-mode escapes.

~b names

Add names to or edit the Bcc: header.

~c names

Add names to or edit the Cc: header.


Read in the dead.letter file.


Invoke text editor.

~f messages

Insert messages into message being composed.

~F messages

Similar to ~f, but include message headers.


Add to or change all headers interactively.

~m messages

Similar to ~f, but indent with a tab.

~M messages

Similar to ~m, but include message headers.


Print message header fields and message being sent.


Abort current message composition.

~r filename

Include file in current message.

~s string

Change Subject: header to string.

~t names

Add names to or edit the To: list.


Invoke editor specified with the VISUAL environment variable.

~| command

Pipe message through command.

~: mail-command

Execute mail-command.


Insert string in text of message, prefaced by a single tilde (~). If string contains a ~, it must be escaped with a \.

Command-mode commands


List summary of commands (help screen).


Execute a shell command.

- [nm]

Print numth previous message; defaults to immediately previous.

alias (a)

Print or create alias lists.

alternates (alt)

Specify remote accounts on remote machines that are yours. Tell mail not to reply to them.

chdir (c)

cd to home or specified directory.

copy (co)

Similar to save, but do not mark message for deletion.

delete (d)

Delete message.

dp (dt)

Delete current message and display next one.

edit (e)

Edit message.

exit (ex, x)

Exit mail without updating folder or user's system mailbox.

file (fi)

Switch folders.

folder (fold)

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:


Previous file


System mailbox


user's system mailbox




File in folder directory.


List folders.

from (f)

Print headers for messages.

headers (h)

List message headers at current prompt.

headers+ (h+)

Move forward one window of headers.

headers- (h-)

Move back one window of headers.


Same as ?.

hold (ho)

Hold messages in system mailbox.


Append list of fields to ignored fields. With no arguments, list currently ignored fields.

mail user (m)

Compose message to user.


Move specified messages to mbox on exiting (the default).

next (n)

Type next message or next message that matches argument.

preserve (pr)

Synonym for hold.

print [list] (p)

Display each message in list.

Print [list] (P)

Similar to print, but include header fields.

quit (q)

Exit mail and update folder.

reply (r)

Send mail to all on distribution list.

Reply (R)

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 (s)

Save message to folder.


Remove ignored fields when saving.


Override saveignore to retain specified fields.

set (se)

Set or print mail options.

shell (sh)

Enter a new shell.


Print size of each specified message.


Read commands from specified file.


Print first few lines of each specified message.

type (t)

Same as print.

Type (T)

Same as Print.


Discard previously defined aliases.

undelete (u)

Restore deleted message.

unread (U)

Mark specified messages as unread.

unset (uns)

Unset mail options.

visual (v)

Edit message with editor specified by the VISUAL environment variable.

write (w)

Write message, without headers, to file.

xit (x)

Same as exit.


Move mail's attention to next windowful of text. Use z- to move it back.

Configuration options

These options are set inside the user's .mailrc configuration file. The syntax is set option or unset option. The system default configuration is in /etc/mail.rc.


Append (do not prepend) messages to mbox.

ask, asksub

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.

escape char

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.

indentprefix string

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.

record file

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.

toplines num

Print num lines of message with the top command. Default value is 5.


Same as -v on command line.

Linux Resources
  • Linux Online
  • The Linux FAQ
  • Linux Kernel Archives
  • Kernel Traffic

  • Sponsored by: