As mentioned in the previous post, if you need to run cron jobs in linux, knowing how to debug them via mail is really important.
By the way, mail
is the older program, the link above is to the man page of mailx
which is the newer program created relatively recently, in 1986!
Navigating through messages in the mailbox is quite a challenge as I found.
So I decided to create a list of the commands which I used most frequently and found useful.
First. to open the mailbox, we type
This opens up the list of unread messages, with arrow on the first message and the cursor next to a ?
at the bottom.
At the prompt next to question mark, entering another ?
gives an equally cryptic help!
That wasn’t so much of a help for me, so after searching around, I came up with the following list of commands which I decided to note down for the future.
- The
U
at the beginning of the message indicates that it is an unread mail - Pressing
Enter
opens the message at the arrow>
Each of the following commands need to be followed by Enter
- To read the next message, enter
n
- To read the previous message, enter
p
- To go back to the list of messages, enter
h
When you go back to the message list, the arrow shows the last message you were on.
If you’ve not deleted any messages while reading them, going back to the list will show an R
against the messages that have been read.
- While reading a message, enter
d
to delete it - While reading a message, enter
u
to mark it as unread - While on the list, to delete a specific mail, enter
d 1
which will delete the first mail - Again, from the message list, to delete a the first three emails, enter
d 1-3
ord 1 2 3
- Finally, while on the list, to delete all messages, enter
d *
- To quit enter
q
Messages is stored in /var/mail/<username>
and that’s the list of messages that show when you type mail
.
However, deleting messages from there, holds those messages under /home/<username>/mbox
However, deleting messages from there, holds those messages under /home/<username>/mbox
To view the messages which have been ‘trashed’, enter the command
mail -f
The same list of commands apply here as well, except that when messages are deleted from mbox
they are deleted permanently and cannot be retrieved any further.
Additional commands on this page.