For directories, severals references say:
- r: we can list directory contents
- w: we can write on directory
- x: we can change to directory (cd into directory).
But in my tests I got following situation:
- my user mateus applies to others permission.
- x is the directory
Only with r
permission for others (chmod 704
):
If I issue ls -l in directory I got this crazy output:
mateus@engsrv:/tmp$ ls -l x/
ls: cannot access 'x/file_teste': Permission denied
total 0
-????????? ? ? ? ? ? file_teste
mateus@engsrv:/tmp$
I can't "cat" the file as well.
mateus@engsrv:/tmp$ cat x/haha
cat: x/haha: Permission denied
Ok, let's se what happen only with w
permission for others (chmod 702
)
mateus@engsrv:/tmp$ touch x/file_test2
touch: cannot touch 'x/file_test2': Permission denied
mateus@engsrv:/tmp$
If I grant execute (chmod 703
), I can write to the folder:
mateus@engsrv:/tmp$ touch x/file_test2
The same happens to read permission (chmod 705)
:
mateus@engsrv:/tmp$ ls -l x
total 4
-rw-rw-r-- 1 mateus mateus 0 Oct 3 17:45 file_test2
-rw-r--r-- 1 root root 3 Oct 3 17:31 file_teste
So, execution (x) is always necessary? but why? is there something else that need execution permission in background?
file_teste
visible in thels
output. The thing to note here is that getting the file metadata isn't possible through just reading the directory, but involves accessing the files themselves. That's probably due to historic reasons and the filesystem structure. There's no execution there, read thex
bit as "access" for directories.