Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a centos server that one of my apps creates files in a tmp folder. The files are always created with the permissions r--r--r-- and i need all the new files in this directory to be created with at the least, the permissions rw-rw-rw-.

How can i achieve this?

EDIT Here's my current setup. I've chmod 777 everything in the /page folder. Then when i run something in my app, it creates or modifies files and they are not rw-r--r--.


ls -ald
drwxrwsrwx 2 tomstest psacln 12288 Aug  2 20:32 .


ls -al
-rw-r--r--  1 tomstest psacln     2 Aug  2 20:32 size
-rwxrwxrwx  1 tomstest psacln     5 Jul 20 16:58 version

My app errors I think because of the line that is rw-r--r--.

share|improve this question
NEVER chmod 777. Is tomstest the user that your app is running as? –  quanta Aug 3 '12 at 3:38
Yes I think it is. –  Catfish Aug 3 '12 at 4:14
Is there a good way to check what user the app is running under? It's a rails app if that's relevant. –  Catfish Aug 3 '12 at 4:16
Actually it might be running as root. The reason it's set to user tomstest is because i chown'd/chgrp'd/chmod'd the entire folder. –  Catfish Aug 3 '12 at 4:17

3 Answers 3

umask 0

Append the command to your ~/.bashrc file to make it permanent.

share|improve this answer

umask can help but DON'T do this. Why did you want to give other user the write (w) permission?

share|improve this answer
Because the app needs to add and delete files and it bombs when deleting those tmp files. –  Catfish Aug 3 '12 at 2:51
What do you mean "bombs"? Why not 664? –  quanta Aug 3 '12 at 2:53
My app throws an error because it can't delete the file. 664 would probably work too. –  Catfish Aug 3 '12 at 3:13
What error? Which user your app is running as? Who is owner of those tmp files? –  quanta Aug 3 '12 at 3:15
It's an error in my rails app. Permission denied is the error. –  Catfish Aug 3 '12 at 3:33

I think everyone else is doing a great job of providing answers, but there's one wrinkle that hasn't been addressed. You specifically mention that your app has a problem when deleting files, but then focus entirely on the protection mode of the files themselves. You should be aware that the ability to delete a file under Unix isn't dependent on the owner or protection mode of the file itself, but of the ownership and protection mode of the directory the file is in. Don't overlook that when seeking the answer to this question!

share|improve this answer
Interesting...I was not aware of this. I'll have to check the owner of the directory. –  Catfish Aug 3 '12 at 13:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.