Search code examples
permissionschmodchownfile-ownershipchgrp

Why did "chown" and "chgrp" changed permissions of a directory? It is not a "chmod"!


Everything was good on my website. Then I ran this:

root@[domain] [/home/[username]/public_html/[foldername]]# chown jaimemontoya -R webroot/
root@[domain] [/home/[username]/public_html/[foldername]]# chgrp jaimemontoya -R webroot/

What I was trying to do with the above was to change ownership from root to jaimemontoya for the webroot directory, and do it recursively. The result was that PERMISSIONS of webroot were changed from drwxr-xr-x to drwxr-x---. As a result, my entire website was down with the following error when visiting the home page:

Forbidden

You don't have permission to access /[foldername]/webroot/[location-name] on this server. Server unable to read htaccess file, denying access to be safe

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

I fixed it by modifying permissions for the webroot directory, changing it from drwxr-x--- to drwxr-xr-x, since originally I was using drwxr-xr-x.

Bottom line: Why did using chown jaimemontoya -R webroot/ and chgrp jaimemontoya -R webroot/ changed PERMISSIONS of the webroot directory? It should have only changed OWNERSHIP, NOT PERMISSIONS. It was my understanding that if you needed to change PERMISSIONS you would need to use chmod, and I never used that. Thank you.


Solution

  • As I mentioned it in the question, I fixed it by modifying permissions of the webroot directory, changing it from drwxr-x--- to drwxr-xr-x. Of course I asked this question because I am trying to understand WHY the problem happened. Nonetheless, I know the solution and that is the most important thing.