I need to set the permissions of a dir so that a usergroup in my ubuntu-server has read/write permissions. I understand that I'm supposed to use chmod (right?), but how do I set the permissions to only apply to a single usergroup?
Asked
Active
Viewed 828 times
1 Answers
1
chgrp $GROUPNAME $DIRNAME
chown g=$PERMS
Where $DIRNAME is the directory you want to change, $GROUPNAME is the name of the group you want the directory to be owned by, and $PERMS is the combination of rwx
that you want to change permissions to.

Scott Pack
- 14,907
- 10
- 53
- 83
-
what is "g" in the second row? – AlexanderNajafi Dec 27 '11 at 16:52
-
@mr.axelander: Group. That only modifies the group level permissions, leaving the user and world permissions unchanged. – Scott Pack Dec 27 '11 at 16:56
-
sry, but i dont understand. Say i want to change the permissions for the dir x to 777 for the group y. What would i then write ? – AlexanderNajafi Dec 27 '11 at 17:02
-
@mr.axelander: You don't. When dealing with permissions in octal, 7 indicates "read/write/execute". Then using `777` what you're saying is, "Give read/write/execute permissions to the user-owner/group-owner/everyone on the file." While technically using '777' will give the group rwx permissions, it also gives *everyone* rwx rights. – Scott Pack Dec 27 '11 at 17:10
-
@mr.axelander I think you have not understood permisions fully. 777 means all persimisions to all. in this first 7 is for owner of the file. 2nd 7 is for group which file owner is a member of other and thrid 7 is for all others. If you want to change permission for a single group , make the dir part of that group and do chmod g+rw
and make sure you have permission to do so in that dir. – bagavadhar Dec 27 '11 at 17:16 -
@ashwin - the file owner is not necessarily a member of the group associated with the file. Of course, from a permissions evaluation standpoint, that doesn't matter, since matching the userid associated with the file means the group and other permissions won't be evaluated. – mpez0 Dec 27 '11 at 17:58