I just learned something that shocked me, because I did not have a clue it was a fact.

If I have a directory with the following permissions:

user@host:~$ ls -la testdir
total 8
drwxrwxrwx  2 user user 4096 Mar  3 20:36 .
drwx------ 34 user user 4096 Mar  3 20:36 ..
-rw-r--r--  1 user user    0 Mar  3 20:36 testfile 1
-rw-r--r--  1 user user    0 Mar  3 20:36 testfile 2

Even though the files testfile 1 and testfile 2 have write permissions only for the owner everyone can write on them.

Until now, I thought that the directories' permissions only affected the directory itself.

So now for my question - what good are file permissions on files, if everything seems to be set by the directories' permissions that the files reside in?

==== EDIT 1 ====

On the other hand look at these permissions:

[user@geruetzel2 default]$ ls -la
total 24
drwxr-xr-x.  2 root root   41 Dec 19 23:07 .
drwxr-xr-x. 96 root root 8192 Mar  3 20:28 ..
-rw-r--r--.  1 root root  354 Dec 19 23:07 grub
-rw-r--r--.  1 root root 1756 Nov 30 19:57 nss
-rw-------.  1 root root  119 Mar  6  2015 useradd

If I do a cat useradd as non-root here, I get a permission denied error. Why is that? The direcory has read permissions for "other" so it should be readable? There seems to be a difference between the two examples I gave but I don't see the reason for the different behavior.


1 Answer 1


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".

If you for example edit a file with vi, it will not edit the file inplace but make a copy and delete the original when saved.
On the other hand, the user not owning the file couldn't echo directly into that file.

  • I understand but on the other hand -> look at my question post edit1...
    – geruetzel
    Mar 3, 2016 at 20:40
  • 1
    actually, thank you - i found the answer. Of course directory read permissions only mean that permission to list files in the directory, not to read the actual files.
    – geruetzel
    Mar 3, 2016 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.