Default Directory Permissions

How do I change the default permissions for a new file created in a directory?

I have a directory used for a group project. When a member of that group creates a file, I want the file to be changed to group read and write, as though they had done a chmod 660 <file> and a chgrp <group> <file>.
bergsyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gruseCommented:
Do a

chmod g+s /your/project/dir

This way, every new created file in this directory will belong to the project group (same group as your project dir). Then check your umask by typing

umask

It's probably 027 or 077. Newly created files typically get 666 (777) permission, but the umask value gets subtracted (well, actually the file's permissions get NOT-ANDed against the umask value). Set the umask value to 007 as in

umask 007

(or 002, if others are allowed to peek), and any file you create now in that dir will have the correct set of permissions. It is easiest to add that command to your shells global profile file (/etc/profile or /etc/bashrc, differs with your login shell), so that every user gets that umask value set at login.

Hope that helped!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jlevieCommented:
If you mean how can I have this automatically happen, the only way would be to change the user's umask to 002.
0
jlevieCommented:
Going off gruse's post...

Setting group id on execution (chmod g+s) just means that files created in that dir take on the group ID of the dir. It does not affect the group r/w modes.
0
bergsyAuthor Commented:
I never knew about the +s attribute on chmod, that helps a lot!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.