Linux – Permissions, owner, group inheritance?

groupslinuxpermissionsusers

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?

Best Answer

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.