From https://unix.stackexchange.com/a/350629/674
For directories, the execute permission is a little different; it means you can do things to files within that directory (e. g. read or execute them).
cd
into a directory needs execution permission, but does it do something to some file in the directory, and if yes, how? The best I can think of is cd
do something to the file .
under the directory, but why doesn't cd
just deal with the directory itself, instead of any file under it, so as to avoid needing execution permission?
Thanks.
cd
needs execution permission of the directory which it applies to, becausecd
calls system call functionchdir()
which requires it. When access a file under a directory, why do we need the execution permission of the directory? Is there some system call function which requires it? – Tim Apr 26 '18 at 13:16open
(look forEACCES
there too).path_resolution(7)
is also worth reading. – Stephen Kitt Apr 26 '18 at 13:25ls
a directory you can’t access). – Stephen Kitt Apr 26 '18 at 17:37