0

This question already has an answer here:

I don't understand restrictions in terms of directories nesting. For example, /var/www/folder/index.html directories. What permissions, owner, group should every directory and file have? Is there such a thing as inheritance here? I mean, do outer's directory permissions, owner, group affect its inner directories and files?

All answers here explain permissions only in terms of one separate directory and a file in it. Nobody pays attention to inheritance.

For example, I want to set up an Nginx server to serve /var/www/folder directory and all its sub-directories and files. How should I think about permissions, owners, groups?

/var - what permissions? what are owner and group?

/var/www - what permissions? what are owner and group?

/var/www/folder1 - what permissions? what are owner and group?

/var/www/folder/folder2/ - what permissions? what are owner and group?

/var/www/folder/folder2/index.html - what permissions? what are owner and group?

marked as duplicate by Ward, Jenny D, mdpc, Cristian Ciupitu, masegaloeh Jul 25 '15 at 10:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • This only partially addresses your question, but the closest thing to "inheritance" is that the user that will ultimately be reading index.html or other files in the must have "x" (execute permission) to each parent directory because that is "traverse" permission which allows it to access subdirectories and "subfiles". Other than that, set the most restrictive permissions you can get away with on the parent folders. – sa289 Jul 23 '15 at 5:33
0

In a word, no. Inheritance does not happen automatically.

Presumably, you will be running Nginx as user www-data, therefore, you would want to give recursive ownership of /var/www to www-data:www-data.

0

inheritance is not provided by standard Unix permission mode.

Anyway, you can have inheritance using two different approach:

  • with a filesystem that supports the POSIX ACLs model (basically, any modern filesystem supports it), you can set a default ACL which will be inherited by newly created files/directories. The acl(5) man page is your friend along with setfacl(1) and getfacl(1).
  • with ZFS, you can use its implementation of "named" ACLs, which is much powerful and basically very similar to what you find under Windows/NTFS

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