Pergunta

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.

Foi útil?

Solução

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.

Outras dicas

I like to think of folders as Gatekeepers. Each folder's permissions allow to you view that folder and any below it. Once you are past one Gatekeeper, you are past it, and the permissions involved in that folder no longer matter. More specifically, the execute permission on folders is actually the ability to enter(list the files within) it. Each file has the permission on whether it is write/read/executable.

So, as long as you have the permissions to view/read the files inside one folder, you can move into a child folder and do whatever that folder gives you permission to do.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top