Linux directory permissions based on group

rmrf

Platinum Member
May 14, 2003
2,872
0
0
I'm creating a folder that is owned by a group, this is what I get when I do an 'ls -l':

drwxrwxr-x 4 <ownera> <groupa> 4906 <date, time> <foldername>

Then I have my users set up to be a member of that group. This works fine up to this point, the users that are a member of the group can write to the folder. However, if another user creates a file, and doesn't grant specific permissions for another user to edit this file, it does not let them. Is there a way so that when users create file and directories underneath this folder, those files will inherit the permissions of the main folder, or at least allow others to modify these files? Also, does it matter who the owner of the folder is, or is having the group permissions at WRX enough?

Thanks
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
You'll wanna use umask for that.
Should be 002 for you, but I'd check the manpage just to be sure ;)
 

rmrf

Platinum Member
May 14, 2003
2,872
0
0
cool, I'll check that out and post back what I find. thanks a lot.

EDIT:

I ran 'umask 002' on the directory that I needed the permissions to be changed. I then created a file as one user, and logged in as a separate user and successfully modified the file. Before I changed the umask, I just ran 'umask' to see what it was set to, and this was the setting: 0022. So by what I have read, this means that the 'write' permission is taken away from group and other, while 0002 allows user and group to write, and takes away write from other.

Thanks again.
 

rmrf

Platinum Member
May 14, 2003
2,872
0
0
Ok, I did notice that when I rebooted, the umask setting dissapeared. So to make it stick, I had to make the last line in my profile: umask 002

Is there a better way to do this so that when I create files in my home directory, it doesn't automatically give those permissions to anyone that is in my group? Maybe set the actual directory that I want this to take place in?

EDIT: Answered my own question on this one. umask works, but every file that you ceate allows your group to modify files. If you instead do a 'chmod g+s <directory>' this means the directory/file will inherit the same group permissions to whatever group owns the parent directory, and automatically set the group owner.

BTW, if you set the umask in your profile, it will set the umask in /etc/bashrc to that setting, and you will have to manually reset that. I suggest using the chmod command.