2

I have a directory which currently hase the following permissions drwxrwsrwx I need to restrict permissions on the files under the directory to read only but when I use chmod 644 I get permission denied on the directory, what chmod command should I use?

Thanks Nic

3 Answers 3

3

Directories need to be executable, so use chmod 755. Since you didn't have the executable bit set, you were not allowed to visit the directory, hence the "permission denied" error.

3
  • Hi Brandon, I've just tried chmod 755 and I'm still able to open, edit and save files under the directory??
    – Nicola
    Jul 9, 2013 at 12:37
  • Do you own the files under the directory? If so, then of course 755 will allow you to read and write them. If you don't want to be able to write them, set it to 555.
    – user235731
    Jul 9, 2013 at 12:40
  • Good point! I'm testing using my own directory, will create one using a different user. Thanks
    – Nicola
    Jul 9, 2013 at 12:43
2

You may also choose to set permissions in multiple steps to ensure the right files/directories are given appropriate permissions. As Nicola indicated directories must be executable and readable (chmod a+rx) but the files may be read only (chmod o-wx).

1

Maybe you don't have permissions on that dir:

sudo chmod 755 <dir>

followed with a password

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .