In my CMS, I noticed that directories need the executable bit (+x) set for the user to open them. Why is the execute permission required to read a directory?
|
|
|||||||||||||
|
|
When applying permissions to directories on Linux, the permission bits have different meanings than on regular files.
|
|||||||||
|
|
First, think: What is a directory? It's just a list of items (files and other directories) that live within. So: directory = list of names. Read bit = If set, you can read this list. So, for example, if you have a directory named
Write bit = If set, you can modify this list i.e. you can {add,rename,delete} names on it. But! You can actually do it only if the execute bit is set too. Execute bit = Make this directory your working directory i.e.
Interesting case 1: If you have write + execute permissions on a directory, you can {delete,rename} items living within even if you don't have write perimission on those items. (use sticky bit to prevent this) Interesting case 2: If you have execute (but not write) permission on a directory AND you have write permission on a file living within, you cannot delete the file (because it involves removing it from the list). However, you can erase its contents e.g. if it's a text file you can use vi to open it and delete everything. The file will still be there, but it will be empty. Summary: Read bit = You can read the names on the list. PS: The article mentioned by KAK is a good read. |
|||
|
|
|
Good article on this. Summary: A directory with its |
|||
|
|
