Email Notifications from a Linux System

This post is not an article about how to receive email notifications from your system, but rather a tip about what should be your very first (No.1) action after a clean installation of a Linux system. It is well known that Linux – and obviously many other *nix systems, if not all – are pre-configured to send email notifications about various system events. That is errors by default, but if you have installed any log analysis and reporting software, like logwatch or epylog (and others), those notifications might include lengthy security reports or reports about resource usage analysis as well. By default, the recipient of all those messages is root@localhost, as it should be. But, since the root account is not for everyday use, it is one the best practices to redirect all root’s email messages to your everyday user’s mailbox.

Recently, I had cleanly installed Fedora 7 on one of my desktop systems and upgraded to Fedora 8 after a few weeks. The last time I had performed a clean installation must have been 2-2.5 years ago, so I forgot to set the email redirection, but I was almost certain that I had done it, so I never checked. The worst thing is that, during my libnotify notification tests, I had set some cronjobs to run every minute. The commands that cron was set to run produced an error and normally the system emailed the output to root after each cron-run. Since I was certain that the email redirection had been set, I never checked root’s mailbox. The result was 19000+ unread messages inside root’s mbox file and email spool.

So, since email notifications are preconfigured, the first thing to do after a clean Linux system installation is to set the email redirection. This can be done with the following:

# echo "root:   youruser" >> /etc/aliases
# newaliases

If it happens that you find root’s or any other user’s mailbox with tons of email notifications from your system, you can delete them by entering the console mail client “mail“:

# mail

…and enter the following command at its prompt:

& delete *

I guess there are many desktop users out there with their root account’s mailbox full of system notifications. At least, for desktop systems, there should a note about setting up the redirection of root’s email to your user’s mailbox.

Email Notifications from a Linux System by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2007 - Some Rights Reserved

George Notaras avatar

About George Notaras

George Notaras is the editor of the G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is an enthusiast self-taught GNU/Linux system administrator. He has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora. He has also developed some open-source software projects in his spare time.

One response on “Email Notifications from a Linux System

  1. Typoid Permalink →

    This does not contain an email adress

    # echo “root: youruser” >> /etc/aliases
    # newaliases

    Where should it be put?