As relates to directories, I am a little confused. Given drw-rw---- how can a user/group view and alter the contents of a directory if they cannot go inside the directory?
For directories, you need the ‘x’ permission (execute) in order to go into it.
So if some user “x” belonging to some group “y” has permissions drw-rw---- for some directory “z” they cannot view or alter the contents of said directory because they cannot enter the directory, or does the x bit only apply to specifically to the cd command in the shell?
Here’s the best explanation I found:
Permissions for directories aren’t exactly the same as they are for files. Here are some typical permissions required on directories:
- Execute permission is required for a user to cd into a directory.
- Read permission is required for a user to use a command such as ls to view the files contained in a directory.
- Execute-only permission allows a user to access the files in a directory as long as the user knows the names of the files in the directory, and the user is allowed to read the files.
- Write permission allows the user to create, delete, or modify any files or subdirectories, even if the file or subdirectory is owned by another user.
As others have said the permissions for directories are different to those for files when traversing the directory. You need the execute permission to go into the directory. Jay did a very good video on permissions that should help you. This can be accessed either from YouTube or from learnlinux.tv homepage. Usually it’s best to add users to groups and give a particular group access to that directory or file(s). Just be careful how you add remove permissions as it can affect, depending on how you do it, sub directories and files. I think Jay covered it in the same video if not it is definitely in one of his others.