CHMOD to make directory writable by group not working

chmodgroupspermissionsvagrant

I'm trying to make the node_modules directory writable by www-group, but chmod isn't working. vagrant (user) is part of the www-data group as seen with the groups command.

Why can't I permit www-data (group) write permissions to this directory?

vagrant@vagrant-ubuntu-trusty-32:/var/www/src/my_app$ groups
vagrant www-data


vagrant@vagrant-ubuntu-trusty-32:/var/www/src/my_app$ ls -l
total 16
drwxr-xr-x 1 www-data www-data  136 Nov 27 22:56 apis
drwxr-xr-x 1 www-data www-data  170 Oct  6 23:24 assets
drwxr-xr-x 1 www-data www-data  170 Jan 15 19:38 controllers
drwxr-xr-x 1 www-data www-data  170 Jan 16 23:00 core
-rw-rw-r-- 1 www-data www-data 1300 Jan 16 23:09 favicon.ico
-rw-rw-r-- 1 www-data www-data 2602 Jan 17 20:03 Gruntfile.js
-rw-rw-r-- 1 www-data www-data 1352 Jan 16 16:27 index.php
drwxr-xr-x 1 www-data www-data  170 Jan 15 19:36 models
drwxr-xr-x 1 www-data www-data  578 Jan 17 03:00 node_modules
-rw-rw-r-- 1 www-data www-data  472 Jan 16 21:11 package.json
drwxr-xr-x 1 www-data www-data  204 Jan 17 01:35 views


vagrant@vagrant-ubuntu-trusty-32:/var/www/src/my_app$ sudo chmod g+w node_modules --verbose
mode of ‘node_modules’ changed from 0755 (rwxr-xr-x) to 0775 (rwxrwxr-x)


vagrant@vagrant-ubuntu-trusty-32:/var/www/src/my_app$ ls -l
total 16
drwxr-xr-x 1 www-data www-data  136 Nov 27 22:56 apis
drwxr-xr-x 1 www-data www-data  170 Oct  6 23:24 assets
drwxr-xr-x 1 www-data www-data  170 Jan 15 19:38 controllers
drwxr-xr-x 1 www-data www-data  170 Jan 16 23:00 core
-rw-rw-r-- 1 www-data www-data 1300 Jan 16 23:09 favicon.ico
-rw-rw-r-- 1 www-data www-data 2602 Jan 17 20:03 Gruntfile.js
-rw-rw-r-- 1 www-data www-data 1352 Jan 16 16:27 index.php
drwxr-xr-x 1 www-data www-data  170 Jan 15 19:36 models
drwxr-xr-x 1 www-data www-data  578 Jan 17 03:00 node_modules
-rw-rw-r-- 1 www-data www-data  472 Jan 16 21:11 package.json
drwxr-xr-x 1 www-data www-data  204 Jan 17 01:35 views



vagrant@vagrant-ubuntu-trusty-32:/var/www/src/my_app$ cd node_modules && mkdir test
mkdir: cannot create directory ‘test’: Permission denied

I also tried using the -R (recursive) flag on the CHMOD command which didn't help, I still can't write to directories; however, I can write to files as the group has write access. Why isn't this working for directories?

vagrant@vagrant-ubuntu-trusty-32:/var/www/src/my_app/node_modules/grunt$ ls -l
total 20
-rw-rw-r-- 1 www-data www-data 1242 May  9  2014 appveyor.yml
-rw-rw-r-- 1 www-data www-data  127 May  6  2014 CONTRIBUTING.md
drwxr-xr-x 1 www-data www-data  136 Oct  2 12:41 internal-tasks
drwxr-xr-x 1 www-data www-data  170 Oct  2 12:41 lib
-rw-rw-r-- 1 www-data www-data 1062 May  6  2014 LICENSE-MIT
drwxr-xr-x 1 www-data www-data 1020 Nov 20 20:29 node_modules
-rw-rw-r-- 1 www-data www-data 2319 Nov 20 20:32 package.json
-rw-rw-r-- 1 www-data www-data  900 May  6  2014 README.md

Best Answer

They might be your groups now but not for the shell you are using.

You can see what supplementary groups you are in in this case by running

grep Groups /proc/self/status

Try relogging in again to see if this fixes the problem.

Related Topic