Linux directory inheritance

Can someone explain to me how directory rights are inherited in Linux (Ubuntu in particular)?

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

folder_A folder_B 

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

My assumption would be that if folder_B had more restrictive permissions, it would override folder_A, but if folder_A had more restrictive permissions then it would redefine its children.

+4
source share
2 answers

Access permissions are explained on the path_resolution manual page: http://linux.die.net/man/2/path_resolution

The only permission in folder A that matters is the permission to search (execute): if you don’t have it, you cannot go down to folder B. Besides, there is no connection between permissions A and B, for example, if A is available is read-only, and B is not, or even if you don’t even have read permission for A, you can still create and delete files in B.

+4
source

I like to think of folders as gatekeepers. The permissions of each folder allow you to view this folder and any of its below. When you pass by one gatekeeper, you pass by him, and the permissions associated with this folder no longer matter. More specifically, permission to execute in folders is actually the ability to enter (a list of files inside). Each file has permission on whether it is a write / read / executable.

So, as long as you have permissions to view / read files inside one folder, you can move to the child folder and do whatever this folder allows you to do.

+2
source

Source: https://habr.com/ru/post/1492300/


All Articles