Can someone tell me what I'm missing here? I'm in a group that owns the "mediawiki" directory and all of its subdirectories, but I can't write to the folder for some reason. I'm connected to SSH, but I've tried re-authenticating to SSH and even rebooting the server.

[02.26.2016/10:50:59] myuser@wikiserver $ ls -la
total 16
drwxrwxr-x  4 www-data www-data 4096 Feb 26 10:45 .
drwxr-xr-x 13 root     root     4096 Feb 23 17:42 ..
drwxrwxr-x  2 www-data www-data 4096 Feb 23 18:20 html
drwxr-xr-x 15 www-data www-data 4096 Feb 26 10:25 mediawiki

[02.26.2016/10:50:59] myuser@wikiserver $ touch mediawiki/test.txt
touch: cannot touch ‘mediawiki/test.txt’: Permission denied

[02.26.2016/10:53:48] myuser@wikiserver $ groups myuser
myuser : myuser adm cdrom sudo dip www-data plugdev lpadmin sambashare

Any advice would be greatly appreciated. I just simply want everyone in that group to be able to write to the mediawiki folder and its subdirectories.

  • Did you log out of your login session and log back in after the file/dir ownership change or group membership change ? If you have more than one terminal open or you have an X-interface running, it is a good idea to exit from everything and come from a clean slate. – MelBurslan Feb 26 '16 at 17:59
  • Yeah I've rebooted, relogged into the user, etc. – user3447014 Feb 26 '16 at 18:06

The group www-data does not have write permissions on that folder, only the owner can write to that directory.


Your group needs this permission drwxr**-**xr-x set it by running sudo chmod 775 ./mediawiki

  • Yes, that would do the trick. But I think you also would have to run chmod -R 775 ./mediawiki to change all subfolders and files. – Thomas Feb 26 '16 at 18:04
  • for existing files and folders - yes ) but question was how to create new ones ) – Ivan Temchenko Feb 26 '16 at 18:05
  • Thanks. Don't I need to add "g" somewhere with chmod so that this only affects the group and not everyone else? – user3447014 Feb 26 '16 at 18:07
  • the permissions contains 3 types of users owner|group|all, and when you setting the permission you do that by numbers: 7 - owner, 7 - group, 5 - all, in total: 775 ;) – Ivan Temchenko Feb 26 '16 at 18:09
  • Check your formatting, and I think you have got the permission wrong: you say they need drwxr-xr-x, but they need drwxrwxr-x. The chmod looks ok though. – ctrl-alt-delor Feb 26 '16 at 18:43

What is the output of $ id? From your question, it is not clear what your primary and secondary groups are.

A user can only write to a directory not owned by him, if his primary group and the group of the directory are the same and the directory has at least g+wx permissions. (Standard UNIX permissions, not considering ACLs)

You could solve this by adding an ACL to the directory:

$ setfacl -m default:user:www-data:rwx,default:group:www-data:rwx mediawiki

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.