跳到主要内容

Linux父子文件夹权限关系

父文件夹有x权限才能进入子文件夹

Do the parent directory's permissions matter when accessing a subdirectory?

https://unix.stackexchange.com/questions/13858/do-the-parent-directorys-permissions-matter-when-accessing-a-subdirectory

The precise rule is: you can traverse a directory if and only if you have execute permission on it.

picture 0

父文件夹的权限只影响文件夹里的内容

父文件夹的权限只影响文件夹的内容, 并不包括对文件夹里文件内部的权限. 比如虽然可以删除文件本身, 但可能无法读取到里面的子文件.

文件夹的内容, 其实包括文件的列表, 但并不包括里面的内容. 比如用vim打开文件夹, 可以看到文件夹列表, 里面包括了一个naming文件夹.

vim ~/nacos


" ============================================================================
" Netrw Directory Listing (netrw v171)
" /Users/gee/nacos
" Sorted by name
" Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:special
" ==============================================================================
../
./
naming/

How do permissions on a directory affect files in it?

https://unix.stackexchange.com/questions/267457/how-do-permissions-on-a-directory-affect-files-in-it

The directory permissions "only" affect the content of the directory. So anybody with write permissions on the directory can e.g. delete files or folders in that directory, even if the permissions of the files or folders are set to have no write access. It maybe makes it easier to understand if you once open the folder with vi or any other text editor. In Unix and Linux "Everything is a file".

picture 1

created at 2023-07-06