0

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?

Green
  • 177
  • 1
  • 2
  • 7
  • 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 05:33

2 Answers2

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
Cristian Ciupitu
  • 6,396
  • 2
  • 42
  • 56
shodanshok
  • 47,711
  • 7
  • 111
  • 180
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.

GregL
  • 9,370
  • 2
  • 25
  • 36
minus8
  • 72
  • 1
  • 1
  • 7