Directory is represented as a file where the data block where each files/subdirectory inside it has an entry:
- Name of file/subdirectory
- inode number
Therefore, when we list directory, we read the names from each entry. When we add/rename/remove files/subdirectories, we update the file by adding/updating/removing the entry that corresponds to the file we added.
Meaning of access permissions on a directory:
read: List files in the directorywrite: Add/remove/rename files in the directoryexecute: Search/lookup files in the directory. It allows us to change into the directory.executepermission is needed to do anything with a directory. Even if we havereadorwritepermissions, we can NOT do anything w/oexecutepermission.
touch test // would create a directory with rwx permissions
chmod u-x test // Remove execute permission
cd test // Error: permission denied
touch test/test.txt // Error: permission deniedWe as users never update directory file directory, ONLY kernel does the update and we only get to read its entries.