I have created a folder, /hello: it has the following permissions:

Owner = rwx
Group = rwx
Others = r

and the folder is owned by john and belongs to the group sales. I have created another user named david and added him to the group sales.

Currently, the files created by john are:

Owner = rw
Group = rw
Others = r

and files created by david are:

Owner = rw
Group = r
Others = r

I do not want files created by john to have write permissions granted by default to the sales group.

I have tried changing the permissions and it resulted in david not being able to write into the directory.


First, concerning the read permission for Others on /hello, you probably want either no read permission at all, or you want Read and Execute permission on /hello. Execute permission on a directory means the user can do an ls in the directory. Read without Exec permission means that the other user would be able to read any file in that directory, but only if they knew the name of the file. It's rare that this is desired.

Second, if files are created by John are always readable by others, then, you can't stop David from reading them.

You can set the default permissions a user creates files as using the umask command. Put this line in John and David's .bashrc (or equivalent):

umask 7

Now, when John creates files in /hello, they will be owner and group of john.

-rw-rw---- 1 john  john  0 Jun 28 22:05 foo

David will not be able to read this file.

Another possibility is, instead of using a group names sales, simply add john to David's group. John will then be able to read/write David's files but not the other way around.

Some other interesting things you might consider. You can set the gid flag on the /hello directory and then when files are created by either John or David, they will be in the sales group. Hence readable and writable by both. Not what you asked for, but this is how you do that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.