LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Group Write Problems (https://www.linuxquestions.org/questions/linux-general-1/group-write-problems-572177/)

gizza23 07-25-2007 10:33 AM

Group Write Problems
 
Hi All,

I hope that I'm writing something that's new. This seems like a topic that would be well documented, however, I've yet to come across an explanation. Here goes...
I've made a folder. I'm the owner and I want group www to be able to write to it. So, I chmod to 775 on that folder. If a new user is in the www as a secondary group, why is he/she unable to write to the folder? It seems so simple but in all the times that I've tried this I've failed. So I believe that I'm missing something fundamental here. Thank you for your help.

Wim Sturkenboom 07-25-2007 11:54 AM

You are the owner, but to which group does it belong.
Code:

wim@desktop1:~$ ls -l
total 4972
-rw-r--r-- 1 wim wim 1249888 2007-06-16 12:08 20070616_120821_P6161254.jpg
-rw-r--r-- 1 wim wim 1364406 2007-06-16 12:09 20070616_120909_P6161255.jpg
-rw-r--r-- 1 wim wim 1250968 2007-06-16 12:09 20070616_120941_P6161256.jpg
-rw-r--r-- 1 wim wim 1186222 2007-06-16 12:11 20070616_121101_P6161257.jpg
-rw-r--r-- 1 wim wim    1706 2007-03-21 18:26 automatix2.key
drwxr-xr-x 2 wim wim    4096 2007-07-17 21:30 Desktop
lrwxrwxrwx 1 wim wim      26 2007-07-17 14:26 Examples -> /usr/share/example-content
drwxr-xr-x 2 wim wim    4096 2007-07-25 18:47 newdir
wim@desktop1:~$

Changing to 775 will not help in this case as the group www will fall under others (marked in red). You can either use 757 for the permissions, but that will allow everybody to write there. So it will be better to change the group ownership of the directory to www:
Code:

chgrp www newdir

gizza23 07-25-2007 02:16 PM

Wow, that was right on the money! chgrp worked just fine. I didn't include something very important in my description though. I had been using chown to make www the owning group of that folder. However, using chgrp did the trick. I wonder whats the difference between using chown and chgrp other than a regular user can use chgrp. Thanks!

Wim Sturkenboom 07-25-2007 10:33 PM

It should work with chown as well
Code:

chown wim:www newdir

bskrakes 07-27-2007 11:53 AM

Owner and Group Permissions -- CHOWN
 
chown lets you change both "OWNER" and "GROUP" where as chgrp just changes the group....

chown win:www /home/win/test_file.txt changes the owner and the group for the file test_file.txt in the home directory of the user win
so if you want to change the group from www to dev_01 you would say, thus keeping the owner as win but allowing the group dev_01 to have access:
chown win:dev_01 /home/win/test_file.txt

chgrp changes just the group factor....

something i learned when changing the group permissions is that you also have to change the permission on the file. an example is when you use samba. lets say and in my case i had permissions on the file user_and_group_list.txt as 744 and wanted to allow all system users to be able to edit it i would have to make it 760 for the permission so that the group can access it. you see the permissions on a file are OWNER|GROUP|PUBLIC. so if i have 777 anyone and everyone can read/write/execute this file - which i dont want. i just wanted the group to be able to access this file and make chances but allow the public to do nothing with the file.

Check out this UNIX File Permissions Tutorial for more information. This should help a lot with any permission problems you may have or may encounter in the future!

Good luck and have fun! Hopefully this little blurb helps you to understand the permissions and ownership a little better and I hope I have not confused you in anyway....


All times are GMT -5. The time now is 02:10 AM.