I'm experiencing a problem having to do with permissions to a directory on my server. The file permissions initially read drwx--S--- and I was able to connect with an FTP client signed in as the directory owner and manage the directory, but when I tryed to view them from a browser I get the "Forbidden" message saying I don't have permission to view the files. I noticed if I use sudo chmod -R 644 my_directory which changes the directory's permissions to drw-r-Sr-- and then use sudo chmod g+x my_directory to change the directory's permissions to drw-r-sr--, I can read the files from any browser, but can no longer transfer or view files via FTP to that directory.


Based on your question I'm going to make an assumption. The web server process is in the same group as the group ownership of the directory.

You removed the execute (x) bit from the directory permissions and only gave it back to the group. This means that the directory owner doesn't have execute permission and that is required to be able to change into/traverse through a directory. Using chmod -R with absolute permissions can be dangerous for this very reason. I would recommend you do the following:

Fix your directory permissions.

sudo find my_directory -type d -exec chmod 2750 {} \;

Since you broke directory traversal you may need to execute this multiple times. If you receive any permission errors while running the above command re-run it until those errors clear.

Fix your file permissions.

sudo find my_directory -type f -exec chmod 0640 {} \;

When this is done your directories should have the following permissions.


And your files should have the following permissions.


If you want to better understand UNIX permissions I would recommend reading man 2 chmod. It's certainly dry reading but it explains what the meaning of each bit is.

  • Thanks for the reply @SeeJayEmm , I want to gain a better understanding of the first two commands you suggested (to fix directory and file permissions). I read through the man chmod 2 & 1 and could not find what the {} accomplishes. I'm assuming this doesn't have anything to do specifically with chmod, could you shed some light on this? – Roger Feb 28 '15 at 22:04
  • You'll want to read through the -exec section of man find. For each file/directory that is found the command after -exec is executed and {} is replaced with the file name. ';' indicates the end of a command but since it's a special char for the shell it needs to be escaped out '\;'. – SeeJayEmm Mar 2 '15 at 1:48
  • In the 1st command find is locating each directory (-type d) and executing 'chmod 2750' on it. In the 2nd command it is locating each file (-type f) and executing 'chmod 0640' on it. This is one way can use explicit permissions in chmod without screwing up the execute bit on directories. – SeeJayEmm Mar 2 '15 at 1:50

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.