3

From this page, http://content.hccfl.edu/pollock/aunix1/filepermissions.htm, I understand that I need the +w bit set in a directory to create a new file and +x bit to cd into it/access its inode. So far, so good. But, I can't use vi/cat/nano/echo etc to do stuff like:

echo hello > dir/file

because I can't access inode of dir. My question is, how do I create/delete/rename a new file in dir if I can't access its inode ? Can I edit the directory structure using

vi dir

and create/edit/rename a new file? Is there a tutorial to do so ?

2 Answers 2

2

If you don't have +x even if you have +w, you can not create new entries in the directory, neither files nor directories.

2
  • 1
    If you don't have +x, to my knowledge, you can't even cd to that directory? And if you can't even cd to that directory, it then implies you can't do any action into the directory? Why not chmod the directory and add +x on it?
    – Darius
    Oct 14, 2013 at 4:43
  • I wanted to understand the point of +w used alone on directories. So, even to create a new file, I need +x ? Oct 14, 2013 at 4:49
5

The x permission on directories is a "lookup" permission. It is needed to get hold of dentry in the directory by name.

Since each and every filesystem operation starts with a lookup on the target path, you have absolutely no access to content of a directory where you don't have x permission. There is thus no point in having w without x, because creating dentries in the directory requires lookup permission there.

The fact that you can't cd is kind of side-effect, because it looks up . inside the directory, not just the directory itself (you still can stat the directory).

You must log in to answer this question.

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