I guess there's something I'm missing here but I need to solve this in order to feel confident while learning how unix/linux OS work.

I've seen some similar questions on this topic but I don't think they solve my problem since both my users have the same privileges.

I have a localhost in my machine.

Inside my var/www/html/ directory I have directory_A created as 'root' user with a web project I developed in it. It works perfectly.

I also have directory_B which I downloaded from github to test a project with my regular user let's say 'regular_user' and I get the following error:


You don't have permission to access /drectory_B/ on this server.

So i check my permissions on both directories and compare them:

drwxr-xr-x 4 root root 4096 Jul 13 20:25 directory_A
drwx------ 5 regular_user regular_user 4096 Jul 13 20:47 directory_B

So I can see my user has permission to read, write and execute. What am I missing here? Why do I get this error when browsing directory_B when I'm supposed to have permission and I don't get it when browsing directory_A when root user has the same permissions as regular_user against this file?

  • 1
    Just reading between the lines here, but is the "Forbidden" error coming from a web server, while the ls output is coming from the local system? The answer to that will point to the eventual answer of users and permissions... – Jeff Schaller Jul 13 '15 at 19:44

When you access the directory via a server/browser combination of any kind, your credentials are not shared, so the server does not know that the person accessing the files is you. Try

chmod a+x directory_B


chmod a+r directory_B/*
  • Thank you for the answer. I'm going to mark yours as the good one because you answered first although I can see both are correct. – ERed Jul 13 '15 at 20:04
  • 4
    Actually, you probably want chmod -R a+rx directory_B. The answer given here probably won't work if you have subdirectories within directory_B. The -R flag ensures that chmod will traverse all subdirectories as well. – D.W. Jul 13 '15 at 21:40
  • 1
    @D.W. Rather chmod -R a+rX directory_B, so as not to make all files executable. – Gilles 'SO- stop being evil' Jul 13 '15 at 23:24
  • good one guys thanks, i was facing the same problem. – Junius L. Jul 14 '15 at 17:36

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.