Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am not great at using the mail command on Linux. How can I get better? I don't even know what program this is. Is it pine? I doubt it. It is in /usr/bin/mail and when I start it is tells me that it is Version 8.1.2 01/15/2001.

When I type list it tells me

Commands are:
next, alias, print, type, Type, Print, visual, top, touch, preserve, 
delete, dp, dt, undelete, unset, mail, mbox, pipe, |, more, page, More, 
Page, unread, Unread, !, copy, chdir, cd, save, source, set, shell, 
version, group, write, from, file, folder, folders, ?, z, headers, 
help, =, Reply, Respond, reply, respond, edit, echo, quit, list, xit, 
exit, size, hold, if, else, endif, alternates, ignore, discard, retain, 
saveignore, savediscard, saveretain, core, #, inc, new

If I type in ? it tells me this:

Mail Command               Description
-------------------------  --------------------------------------------
t [message list]           type message(s).
n                          goto and type next message.
e [message list]           edit message(s).
f [message list]           give head lines of messages.
d [message list]           delete message(s).
s [message list] <file>    append message(s) to file.
u [message list]           undelete message(s).
R [message list]           reply to message sender(s).
r [message list]           reply to message sender(s) and all recipients.
p [message list]           print message list.
pre [message list]         make messages go back to /var/mail.
m <recipient list>         mail to specific recipient(s).
q                          quit, saving unresolved messages in mbox.
x                          quit, do not remove system mailbox.
h                          print out active message headers.
!                          shell escape.
| [msglist] command        pipe message(s) to shell command.
pi [msglist] command       pipe message(s) to shell command.
cd [directory]             chdir to directory or home if none given
fi <file>                  switch to file (%=system inbox, %user=user's
                           system inbox).  + searches in your folder
                           directory for the file.
set variable[=value]       set Mail variable.

I type z and it shows me the end of the list of messages - but that command is not showing up in the ? help page.

My biggest questions are:

  1. What program is this?
  2. How can I learn it better? Are there some links to tutorials?
  3. MOST IMPORTANTLY How can I get back to the message list after I run another command (or refresh the message list, or move up and down in the message list??)
  4. What are the most command commands, or what are the most helpful tricks to using it?
  5. What is the opposite command of z for scroll down the list page by page?

Clarification: I'm asking about how to use the interactive program and not the scriptable command - i.e. what happens when you just type mail with no flags or parameters. I only seem to be able to find tutorials online of how to script with the program, not how to use it. I know it hasn't been updated since 2001, I would just like to get a little more efficient at using it and I'm having a hard time finding resources to do that.

share|improve this question
Actually, z is in the first list of commands, near the end of the fourth line (fifth counting "Commands are:"). – jwodder Dec 14 '11 at 3:15
hmm, cool. What is the opposite of z then? It's not a and I couldn't figure it out :) – cwd Dec 14 '11 at 4:07
up vote 42 down vote accepted

This page describes the interactive command in detail, and is in fact a fairly thorough tutorial. Describes commands such as z and z- :

If there is more than a screenful of messages, then z will
show the next screenful, and z- will show the previous screenful.

Hope that helps.

share|improve this answer
Also h reprints the current screenful – qwertzguy Dec 15 '15 at 15:07

mail isn't Pine; it's just mail. In a perfect world, your version of mail should be compatible with POSIX/SUS's mailx program (The most relevant documentation being under the "Extended Description" heading), but, as usual, determining the deviations from perfection is left as an exercise to the reader.

share|improve this answer

As its manual states, mail is:

mail is an intelligent mail processing system which has a command syntax reminiscent of ed(1) with lines replaced by messages.

That is to say, you could think of it as a quick way to perform some tasks related to the mails you receive in the server you are working on.

The power of mail can be understood when writing shell scripts or cron jobs for example.

To learn it better, I've found some articles about mail command:

Another question made on this site deals with the same issue:

share|improve this answer
Sorry, I tried to write the question so it would be clear that I'm not asking about the scripting properties of the command as much as I'm asking about the interactive ones - i.e. just typing mail with no parameters. – cwd Dec 14 '11 at 1:30
you filtered the key line from the mail man page. This fact had escaped me. After then looking at ed's man page I was able to navigate more easily, albeit still with some difficulty. $ goes to the most recent message, typing a number jumps directly to that message, - goes backward, + or n goes forward (but p does not go backwards) – Paul Aug 13 '14 at 13:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.