Do I correctly understand permission to directories in Linux/Unix?
If your directory has only
r(read) permission you are allowed to see the content of the directory (which files are located there) but you cannot do it because you cannot go (cd) to this directory (because of the absence ofxpermissions). You also cannot see the content of the directory (which files are located there) from outside of the directory (for example byls directoryname/*). You also will be unable to read (see) content of files located in such a directory usingcatandmorecommands (even if you have permissions to read these files). You also will be unable to modify (write) files (even if you have write permissions to them) if these files are located in such a directory (no matter what you trycat >>,echo >>,cpor some text editor). So, from my point of view, to have onlyrpermissions to a directory is equivalent to having absolutely no permissions to the directory.If your directory has only
x(execute) permissions you are allowed to go (cd) into the directory but you are not allowed to see (ls) the content of the directory (because you do not have permissions to read the directory). If a directory has onlyxpermission and it contains a file for which you haver(read) andw(write) permissions, you still well be unable to open this file with (at leas some) text editors (for examplemcedit). But you will be able to read context of the file using such commands ascatormore. You alls will be able to modify content of the file usingecho >>orcat >>. So, it seems to me, that it isxwhat allows users to "read" and "write" existing files in the directory (if files have the corresponding permissions too).If a directory has
randxpermissions but now(write) permissions, you cannot change content of the directory (set of files which are located there). For example you cannot create a new file there or remove existing in the directory. But you still are allowed to change content of existing files. So, you needwpermissions to create or remove files in the directory.Added:
It is also interesting to mention that
wpermission to the directory is necessary but not sufficient to create and delete files in the directory. If a directory has onlywpermission you will be unable to add/remove files from/to the directory. To be able to do so, you need to havexpermission to the directory (additionally towpermission).