"You have new mail" message in Linux

When logging into your Ubuntu or Debian server, you might be greeted with the message You have new mail in /var/mail/root. But how do you read that mail and how did it get there?

It means that you have installed sendmail on Ubuntu (or any other flavour of Linux) and you received one or more messages in your inbox. The message(s) can originate from your system itself, or from an external e-mail address.

Read your messages in Ubuntu or Debian

To see what messages you received from the command line, this command will reveal the message(s):

Show mails in /var/mail/root:

cat /var/spool/mail/root

The message could look like this:

From root@sisrv.net  Mon Oct 19 00:00:01 2020
Return-Path: <root@sisrv.net>
Received: from sisrv.net (localhost [127.0.0.1])
        by sisrv.net (8.15.2/8.15.2/Debian-14~deb10u1) with ESMTP id 09J001q3000577                                                                         
        for <root@sisrv.net>; Mon, 19 Oct 2020 00:00:01 GMT
Received: (from root@localhost)
        by sisrv.net (8.15.2/8.15.2/Submit) id 09J001dm000553
        for root; Mon, 19 Oct 2020 00:00:01 GMT
Date: Mon, 19 Oct 2020 00:00:01 GMT
Message-Id: <202010190000.09J001dm000553@sisrv.net>
From: root@sisrv.net (Cron Daemon)
To: root@sisrv.net
Subject: Cron <root@4b4593bb> sudo tar -zcf /home/Backups/ircd_backup-$(date +%Y--%m-%d).tar.gz /home/ircd                                          
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>

Removing messages from /var/mail/root

To purge these messages and to get rid of the message you received on logging in, you can simply delete it with this command:

Purge messages from /var/mail/root

Simply type the following command at shell prompt to delete all root mail:

> /var/spool/mail/root

Do not forget to include the > sign, otherwise it won’t work.

Verify it with the following command or cat command or ls command:

mail
cat /var/spool/mail/root
ls -l /var/spool/mail/root

How to remove root user’s email every day using cron job

Simply run the following cron job:

@daily > /var/spool/mail/root

 

  • You have new mail, debian mail, ubuntu mail, delete mail in linux
  • 142 Benutzer fanden dies hilfreich
War diese Antwort hilfreich?

Verwandte Artikel

How to Set Up a Mac for Your Kids

Providing children with access to a computer and the internet is increasingly important, but so...

How to Get Help With a Command from the Linux Terminal

Whether you’re an inexperienced terminal user or a grizzled veteran, you won’t always know the...

How to change the ssh port on Linux

To Change the SSH Port for Linux Server Connect to your server via SSH Switch to the root...

How To Install screenFetch in Linux

If you've browsed Linux groups on social media, you've probably seen a lot of screenshots that...

Static IP vs. Dynamic IP Address

A static IP address is one that remains fixed and never changes. The PC always sees the same...

Powered by WHMCompleteSolution