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.


2 Answers 2


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
    Commented 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
    Commented Mar 3, 2016 at 20:52

No, files without permissions can not be written to. -- But they can be deleted and a new file with the same name can be created. For that you need the write permissions of the directory they are contained in.

With a directory...

  • you can do almost nothing without x permission
    • with r alone you can only list its content non-recursively, names only, you can not even distinguish if an entry is a directory or a file nor open any
  • with x alone you can
    • cd into that dir
    • access all files and subdirectories read-write including permission settings (subject to their own permissions), if you know their name
  • with w alone you can do nothing(!?)
  • you need x and w to
    • add an entry (i.e. create a file/dir)
    • remove an entry (i.e. delete a file or empty directory)
      • you need zero permissions of the file itself to do so
      • non-empty directories can never be removed...
      • ...and missing permissions of a subdir might block the owner of the parent from removing its content, i.e. recursive removal
  • to operate on dir1/dir2/dir3/file you need
    • x of dir1, dir2 and dir3
    • some permissions of dir3 and/or file, depending on the operation

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .