1

I am member of couple of groups lets say Master, Student, Web. The problem is that by default whatever I do is first created under student group. I need to set it so it is created with Web group.

Folder www/ where I need to write file is already mode 770. But because it picks up my student group it does not allow me to write to that folder.

Is there any way to change the group that I create files under.

If I execute groups it lists all groups so I am member of correct group I just cant write to the folder.

Anyone?

4 Answers 4

0

If you do 'id', you'll see your primary group, listed as something like gid=1000(student). By default, all files will be created with that group.

However, that is not your problem. If you are a member of a group which has write permission to a directory, then you can create a new file.

Are you sure that the permissions on www is correct? Do 'ls -ld www'.

0

Are you sure you're in the correct web group? On Ubuntu this probably means running usermod -a -G www-data yourname alternately, www might have incorrect permissions. Make sure it's set so that group members have read/write access: chmod -R 770 /var/www.

0

If you want to permanently change the user's default group, use usermod (manpage):

# set "web" as the primary group for user "username"
$ sudo usermod -g web username

Or, you can put newgrp web (or whatever the group name is) in your .bashrc, somewhere near the end of the file, to get "logged into" the Web group each time you login -- without changing your user's primary group. newgrp (manpage) sets the "effective group ID". Watch:

# what's my current effective GID?
$ id -g
1000

# "login" to another group 
$ newgrp www-data

# now what's my effective GID?
$ id -g
33
0

Unless there's something unusual about Ubuntu, if you make the permissions on the target directory 'SGID', then all files created in the directory will belong to the group that owns the directory:

chmod g+s /var/www

Now all files under /var/www will, by default, be created with the 'web' group that (I assume) owns the directory.

MacOS X defaults to this behaviour even if the SGID bit is not set on the directory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .