Get rid of new mail message in linux unix terminal

I had a message that was returning every time I was using Terminal on my local machine. It says that I had unread mail in /var/mail/$USER. But how can you read this mail and how can you get rid of this?

It’s mail that has been send by for example a local install of WordPress or it’s a cronjob which sends reports on cron-jobs which you ran locally. You can of course see if you can disable the mailings. But you also want to read the mails first (what they are about) and get rid of this message that keeps appearing when starting terminal/CLI (so you need to get rid of the emails).

First reading the messages can be done by running:

$ cat /var/mail/$user

Then removing the mail can be done by following the following commands:

$ mail
> d *
> quit

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.