Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like the Linux filing system to set a specific group when new files and directories are created by different users under a specific directory. I know I can use chmod to change existing files and directories but I want it to happen automatically. Does anyone know how?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

The standard user/group/other security model in Unix doesn't support this. The closest you can get are the "sticky" bits to assign ownership and group to newly created files.

However, you tagged this acl, and that might open the door: you can set a default ACL that will be inherited down the tree; see the -d switch to setfacl(1), and the details under "automatically created entries" in the same manual page to understand how that works.

http://www.vanemery.com/Linux/ACL/linux-acl.html#default has further examples of how to use these tools.

If all you needed to do was make sure new things got created with a specific directory, though, that is much easier:

chgrp some-group /path/to/directory
chmod g+s /path/to/directory

That has no influence over file mode, just file ownership.

share|improve this answer
    
Wouldn't the sticky bit for the group solve his needs? –  jjmontes Feb 19 '12 at 20:10
1  
@jjmontes - I don't believe so, since he talks about chmod rather than chown. Rereading, though, it could be that was a typo for chown, and the sticky bit would solve the problem. That would be chmod g+s /path/to/directory –  Daniel Pittman Feb 19 '12 at 20:13
    
@Daniel Pitteman:Sorry I did mean chown not chmod :) –  James Feb 19 '12 at 20:48
    
Then @jjmontes was on the money. Use the sticky bit on the directory to get the behaviour you want. –  Daniel Pittman Feb 19 '12 at 20:52
    
Yes the ACL stuff worked. I used this specific command: setfacl -R -m d:u::rwx,d:g:homework:rwx,o::- /home/Homework –  James Feb 19 '12 at 21:18
add comment

Your Answer

 
discard

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.