-   Linux - Newbie (
-   -   Umask Per Dir (

m2azer 07-16-2008 06:14 PM

Umask Per Dir
I am trying to share a dir between several users whom I added all to same group. by sitting the GUID on the shared folder all newly created folders/files owned by that group but the system wide umask is 0022 - so when a new file is created its permission is "rw r r" - is there a way to get around this issue and have all newly created files be writable by the group as well.

jailbait 07-16-2008 06:36 PM

I don't think that the umask can be set for a directory. It can be set per user.

You can set the umask for individual users in /home/user/.bashrc or /home/user/.profile (the file used varies from distribution to distribution). Put this command in /home/user/.bashrc for each member of the group which shares the directory:

umask 002

This does not do exactly what you asked. Now each user will create all directories with permissions 775 and all files with permissions 664. This includes all files and directories in the shared directory and all files and directories outside of the shared directory. That may or may not be acceptable as a solution to your problem.

Steve Stites

Mr. C. 07-16-2008 07:18 PM

To clarify a bit more, umask is a per-process setting, having nothing to do with the file system itself. Rather, each process starts with the umask of its parent process (in your case, likely the shell). An application may change its own umask, and there are no restrictions on this. The umask is simply a mask that zero's portions of the default file creation modes (in open(), creat()).

You would need a special "shell" to prevent a user from changing their own shell process' umask, but it would also have to control which programs could be exec'd, etc. This gets into a more restrictive shell (like rsh, the restriced mode of the shell, not remote shell)..

stress_junkie 07-16-2008 07:45 PM

Ignore this.

All times are GMT -5. The time now is 12:42 PM.