Umask?

Steven W. Orr steveo at syslang.net
Tue Apr 4 13:21:01 EDT 2006


On Tuesday, Apr 4th 2006 at 12:09 -0400, quoth Ken D'Ambrosio:

=>Hey, all -- someone on a BBS I'm on asked about how to set default
=>permissions on files, and I immediately thought of "umask"... which
=>appeared to not be installed on my Debian box.  So I plugged it into
=>Debian's search page, and got essentially nothing.  Is "umask" not used in
=>Linux?  Has it been deprecated?  If so, what was it replaced with?  Etc.,
=>etc., etc...

umask is a system call and a shell command in every shell. The idea is 
that the value that umask is set to is subtracted from the default 
permission of every file you create. So if your umask is set to 022 and 
you link an executable which would normally have a default permission of 
777 then the resulting file would have a permission mask of 0777 - 022 == 
0755. IOW, only the owner can write. Everyone else can read and execute.

The umask value of a process is one of those attributes that are inherited 
by child processes, which is why umask has to be builtin to the shell. 
i.e., if you had a seperate process to set a umask value then the process 
would exit and the invoking process would remain unaffected. That's why 
the umask value that you want should not be set in your .bashrc Instead it 
should be set in your .bash_profile (assuming you're using bash), the same 
as setting your environment variables.

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



More information about the gnhlug-discuss mailing list