Q. I've CentOS Linux acting as router for our small community based college. I see logwatch and other cron job generating emails for root account. How do I delete those emails? I don't want to disable email facility but just wanted to get rid of all root emails.
A. The easilst way is to empty root / users email message file i.e. /var/spool/mail/root or /var/spool/mail/username. Simply type the following command at shell:
> /var/spool/mail/root
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop














{ 18 comments… read them below or add one }
Nothing happens when I type /var/spool/mail/root to purge the root user’s mail messages.
I think you meant,
#cat /dev/null > /var/spool/mail/root
– Nirmal.
Thanks, it worked!
because you need type > before file to clear…
Cheers, had forgotten all anout dev/null, thanks!
You just did oversee the > in front of /var/spool/mail/root
Works like a charm…
Thank boss……..it’s an important command
Great thanks for the command
mail
d 1-x
d = delete
1-x = mail 1 to mail x (e.g. d 1-53)
Here the simple way to delete all mail
echo ‘d *’ | mail -N
Thanks!
It works!!
I’ve tried that but received this message: ‘Value too large for defined data type’ :-(
can anybody help me?
thanks from now !!!
Thank you for advice worked..
gud information.worked great.
Thanks….
Use Nirmal’s solution above:
`cat /dev/null > /var/spool/mail/root`
Not the correct way.
Use biff or edit your .bashrc to add:
unset MAILCHECK
You can’t cat /dev/null; it is a block special device. It also outputs nothing and closes right away; it is the same as the original post in concept. the Null device is a place to output stuff you don’t want, its opposite would be ‘/dev/zero’. The original one doesn’t work because it is unbalanced- there is nothing going into the file.
‘exit > /path/to/file’
Is basically what the cat /dev/null does. You want
echo > /path/to/file. instead.
to empty the mail file
#cp /dev/null /var/mail/root
Can i eat near my Linux server or is this bad practice?