{ 23 comments… read them below or add one }

1 Nirmal Pathak February 19, 2009 at 4:03 pm

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.

Reply

2 Jorge Tarlea October 12, 2010 at 11:01 am

Thanks, it worked!

Reply

3 Adam Ziaja September 28, 2011 at 10:15 am

because you need type > before file to clear…

Reply

4 Cian March 31, 2009 at 3:55 pm

Cheers, had forgotten all anout dev/null, thanks!

Reply

5 Kaspar September 10, 2009 at 8:00 pm

You just did oversee the > in front of /var/spool/mail/root
Works like a charm…

Reply

6 Md. Mizanur Rahman November 4, 2009 at 8:44 am

Thank boss……..it’s an important command

Reply

7 Sunil April 21, 2010 at 7:15 am

Great thanks for the command

Reply

8 //Sessl December 10, 2010 at 2:39 pm

mail
d 1-x

d = delete
1-x = mail 1 to mail x (e.g. d 1-53)

Reply

9 Khupcom December 12, 2010 at 10:55 pm

Here the simple way to delete all mail
echo ‘d *’ | mail -N

Reply

10 fukid October 14, 2011 at 5:04 am

Thanks!
It works!!

Reply

11 wolvies December 12, 2011 at 9:29 am

I’ve tried that but received this message: ‘Value too large for defined data type’ :-(
can anybody help me?

thanks from now !!!

Reply

12 baanmaha April 9, 2011 at 1:54 am

Thank you for advice worked..

Reply

13 Santosh Sheelvant June 2, 2011 at 7:36 am

I have deleted the file “root” from /var/spool/mail itself and from then on nobody is receiving the emails upon our transactions.

Please suggest me a solution if any?

Reply

14 linux course July 19, 2011 at 4:28 pm

gud information.worked great.
Thanks….

Reply

15 Mars January 25, 2012 at 9:54 pm

Use Nirmal’s solution above:

`cat /dev/null > /var/spool/mail/root`

Reply

16 J February 27, 2012 at 10:28 am

Not the correct way.

Use biff or edit your .bashrc to add:

unset MAILCHECK

Reply

17 James October 9, 2012 at 11:05 am

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.

Reply

18 adiss February 9, 2013 at 10:26 am

to empty the mail file

#cp /dev/null /var/mail/root

Reply

19 banjo May 14, 2013 at 4:24 am

Can i eat near my Linux server or is this bad practice?

Reply

20 Paul Thomson October 5, 2013 at 7:04 pm

Fantastic! – Just cleared 35000 unread mail items ;-)

Keep up the good work, stay safe!
Paul :-)

Reply

21 Dave March 2, 2014 at 1:59 am

none of this works

Reply

22 Aijaz March 16, 2014 at 7:25 am

what will be the impact if I use the command for oracle file which is more than 3 gb .If there is no bad impact ,can i execute on Production server,can I get any script

cat /dev/null > var/spool/mail/oracle

Reply

23 vietiso April 4, 2014 at 9:04 am

Leave a Comment

Tagged as: , , , , , ,

Previous Faq:

Next Faq: