Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
$ whoami
$ cd /var/www
$ sudo mkdir html
$ sudo groupadd web
$ sudo usermod -a -G web meder
$ sudo usermod -a -G web medertest
$ sudo chown meder:web html
$ sudo chmod -R g+rwx html

The problem is, anytime I create a new file in /var/www/html even though the group is set to web, it is only writeable by the original user.

I was given the advice of setting the umask to be 002 because the default is what causes the problems. But I would have to do this for all users in that group, and as far as I know it would be tedious having all of them modify ~/.bashrc to have umask 002. Even if I can do it myself with a shell command for all of those users, it still seems too tedious.

Can anyone offer any advice on having a group writeable directory?

share|improve this question
Have you tried logging out and then logging again with the user meder? Group information is not updated in the current session. – marco Jan 6 '11 at 18:52
@marco - I did su medertest and su meder like a thousand times. Does that qualify as a log out? – meder omuraliev Jan 6 '11 at 19:12
@marco thanks did not know that group info is not updated in the current session... bummer – gabeio Apr 23 '15 at 0:43
up vote 18 down vote accepted

First, enable the SGID bit on your directory:

sudo chmod g+s html

This will make new files created inside that directory inherit the parent's group ownership.

There is no inheritance of permission levels in the POSIX permission model. However, this can be done with Access Control Lists, without having to worry about umask settings:

sudo setfacl -d -m group:web:rwx html

It's a real bummer that umask cannot be assigned on a per-directory basis.

share|improve this answer
what's g+s in numbers? – Michelle Jul 23 '13 at 6:39
@WearetheWorld prepend with 2: chmod 2XXX file. – mizo Jul 23 '13 at 11:46
I have been hunting around for this answer forever, and I just got referred to it via a Twitter response. Thanks @mizo! – Glyph Jul 27 '14 at 19:27

You need to set the setgid bit on the directory.

chmod g+s html
share|improve this answer
Can I combine this chmod with the g+rwx one? – meder omuraliev Jan 6 '11 at 19:47
@meder: yes g+rwxs – Dennis Williamson Jan 6 '11 at 19:54
This only preserves directory ownership, not directory permissions. – Glyph Jul 27 '14 at 19:26

Your Answer


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.