Linux .forward file not working? Make sure you have the permissions set correctly
I checked in to one of my Linux accounts today and saw that I had about 2 GB of unread emails.
Dating back to 2008, these emails were almost entirely the output of different cron jobs that I have set up & running on that account. They were error notifications & various STDOUT messages. Nothing really major, just informational type stuff. Mostly stuff I don’t really need to know about, just the result of some sloppy coding on my part. (Like STDOUT messages I should have stripped from the code before running the job via cron.)
I was a little surprised, because I *thought* I had an email forwarder set up on that account. I did, but it was not set up correctly. (Obviously.)
The problem was really simple, and just something I overlooked – I had forgot to set the permissions of the .forward file correctly, so it was being ignored by the Linux system.
I thought I’d post here in case anyone else made the same mistake.
How to set up a Linux .forward file correctly
1. Create a file called “.forward” in your home directory. If your username is “billg”, the file should (likely) be created at “/home/billg/.forward”. Stick the email address you’d like to forward emails to in that file. You can accomplish this quickly from the command line using the command “echo ‘billg@microsoft.com’ > /home/billg/.forward”
2. After you’ve done this, make sure you set the file so that it’s not world-writeable! (This is the step I overlooked). “chmod 644 /home/billg/.forward”
That’s it – your email should be forwarded correctly.
The reason it doesn’t work when the permissions aren’t set correctly is a security thing – just imagine the risks if anyone was able to write to your .forward file. As a precaution, the system will ignore the .forward file if it is world writeable.


Leave a Reply