{ 18 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 linux course July 19, 2011 at 4:28 pm

gud information.worked great.
Thanks….

Reply

14 Mars January 25, 2012 at 9:54 pm

Use Nirmal’s solution above:

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

Reply

15 J February 27, 2012 at 10:28 am

Not the correct way.

Use biff or edit your .bashrc to add:

unset MAILCHECK

Reply

16 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

17 adiss February 9, 2013 at 10:26 am

to empty the mail file

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

Reply

18 banjo May 14, 2013 at 4:24 am

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

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , , , , , ,

Previous Faq:

Next Faq: