View Full Version : how to recover /var/spool/mail/user ?

15th July 2004, 08:24 AM

dont ask how but i deleted my user in the "/var/spool/mail/user" directory and was curious if there is a way to get it back? :confused:

15th July 2004, 10:12 AM
A quick Google for "undelete linux" found this:


No idea if "undelete" works - it could wreck your disk, so buyer beware!

BTW, unless you were actually running a mail server (e.g. sendmail), I doubt /var/spool/mail/user was even updated - it's still zero length on my FC2 install (hey, but I read mail on work machines via ssh, so I don't count).

15th July 2004, 11:59 AM
appreciate it but thats not what i was looking for. its just 1 file i need to recover, not any whole directories like that.

15th July 2004, 02:55 PM
Did you have mail in the file you need to recover? If you do it will be tricky to recover, and I don't know how.

If not just make an empty file in the directory:
touch /var/spool/mail/user This will have to be done as root.

16th July 2004, 01:41 AM
i did create a file with my username but when you "touch" a file its not the same type of file that is supposed to be there i believe. when i tried this, id run mutt and it would complain about /var/spool/mail/user not being there when infact it was. nah, i didnt have mail in it as far as i remember. i think the file type is .mbx or similar.

16th July 2004, 05:35 AM
I'm guessing you might have ownership/file permission issues. As root try the following...

touch /var/spool/mail/user
chmod 600 /var/spool/mail/user
chown user /var/spool/mail/user
chgrp user /var/spool/mail/user

Mailbox files are text files like anything else; touch updates a file's timestamp (creating it if it doesn't exist) to the current time... cp /dev/null /var/spool/mail/user would achieve the same results in this case.

16th July 2004, 09:17 AM
very cool, thanks that worked. :)