I have setup up a Group that includes a few users (mygroup) then have set the owner of a web directory to be apache and the group to be mygroup.

chown -R apache:mygroup /home/myweb

Then I have set permissions to

chmod -R 764 /home/myweb

The idea being all can view, apache can read,write and execute and mygroup can read and write.

But now when I try and use ssh2 in php to create a folder in /home/myweb it doesn't work because of permissions.

The user ssh2 connects with is part of mygroup as is apache.

As far as I can tell I have the right settings.

closed as off-topic by user9517, HBruijn, Ward, MadHatter, Cristian Ciupitu Nov 9 '14 at 5:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – user9517, HBruijn, Ward, MadHatter, Cristian Ciupitu
If this question can be reworded to fit the rules in the help center, please edit the question.


The x permission on a directory determines whether you're able to traverse into it, which is required to write files. If you want mygroup to have write permissions, it needs execute permissions as well. Additionally, a value of 4 will allow other users to see which files are in the directory, but unable to read the files, nor even see what the sizes are. You want 775 for the directories to accomplish what you've described.

Since what you really want is for files to have one set of permissions, and directories to have another, I would suggest you run these commands.

find /home/myweb -type f -exec chmod 764 {} \;
find /home/myweb -type d -exec chmod 775 {} \;

The first find command looks for all items of type f (Files) and executes chmod 764 for each match, replacing {} with the name of the file it found.

The second find does the same thing, except it looks for directories, and sets the permissions to 775.

  • Is it not a problem giving Others the ability to execute files I would have thought that should not be allowed where possible? – Kline Oct 29 '14 at 17:51
  • That's the problem with using recursive. You're changing both files and directories. That's fine for Read and Write, but Execute means different things between the two. I'll add an edit for how to set the directories to one thing and the files to another. – Omnipresence Oct 29 '14 at 17:54
  • Can I run a command recursively that just targets files or directories? – Kline Oct 29 '14 at 18:00
  • I'm still confused by this are you saying it's always ok to give Others execute permissions on directories? – Kline Oct 30 '14 at 11:02
  • Yes, because you don't actually Execute a directory. For example, if you don't have execute permission on a directory, you're unable to cd into that directory, even if you had read and write permissions on it. Execute on a directory doesn't grant execute to files within the directory. – Omnipresence Oct 30 '14 at 13:21

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