Linux directory permission inheritance

Evan LaHurd picture Evan LaHurd · Jul 19, 2013 · Viewed 8.5k times · Source

Can someone explain to me how directory permissions are inherited in Linux (Ubuntu, specifically)?

For example, what if I have the following directory structure:

folder_A
    folder_B

Do folder_A's permissions always override folder_B's? Is there any difference if folder_A's permissions are more restrictive than folder_B's, or vice-versa?

My guess would be that if folder_B had more restrictive permissions, it would override folder_A's, but if folder_A had more restrictive permissions, then it would override its children.

Answer

Joni picture Joni · Jul 19, 2013

The way permissions affect paths is explained in the path_resolution man page: http://linux.die.net/man/2/path_resolution

The only permission on folder A that matters is the search (execute) permission: if you don't have it you can't descend to folder B. Other than that there is no relation between permissions of A and B, for example if A is read-only and B is not, or even if you don't even have read permission to A, you still can create and delete files in B.