What is the "You have new mail" message in Linux/UNIX?
Where is this mail?
It's likely to be in the spool file: /var/mail/$USER
or /var/spool/mail/$USER
are the most common locations on Linux and BSD.
(Other locations are possible – check if $MAIL
is set – but by default, the system only informs you about /var(/spool)/mail
.)
Usually the spool file is in a very simple mbox format, so you can open it in a text editor or pager.
For a slightly more convenient way, most distributions come with a program called mail
(or Mail
, mailx
). You can try mutt
or alpine
; you can even configure it to be sent to an outside mailbox. (See "is this real mail?" below.)
What does it contain, and who/what sent it?
Most often the messages contain output of cron jobs, or a system security report by logwatch, or similar junk. Read it and find out.
How important is it?
Depends greatly on the contents of each message.
You should at least scan the subject headers – often people ignore the mail for months never realizing that their daily cron jobs fail.
Is this even actual "mail" in the same sense as email? Or is it just my system telling me something?
Yes to both – it's generated by your system telling you something, but it's also actual email and can be handled as such.
You can (and should) configure your mail software – the "MTA" aka /usr/sbin/sendmail
– to forward the messages to your personal mail address. The exact instructions vary depending on which MTA (if any) you have installed, whether this is a personal computer or a server, whether you have your own domain or use a @gmail.com, and so on.
Note that /usr/sbin/sendmail
nowadays is a shared API and doesn't necessarily mean the original Sendmail MTA. In fact, you shouldn't use Sendmail, but something more modern like OpenSMTPD, Postfix, or Exim4. All of them provide the same /usr/sbin/sendmail
tool, but they're easier to configure, more secure, and just as powerful.
The easiest way for me was to run the following in a terminal:
cat /var/spool/mail/root
For anyone wondering how to read these messages one by one, you can just use 'mail'
$ mail
Then type a message number from the list which you want to read.
To goto the next message you can type 'next', another useful command is 'delete'..
To see more about how the mail
program works, see the output of man mail
.