Showing results for 
Search instead for 
Did you mean: 

umask command

Frequent Advisor

umask command

Hi all,

Can anyone explain the exact reasons why the following umask setting '002' expectedly applies a directory permission default of its invers (755) bu applies something like a 664 to all its containing files. Is there a specific reason for this? and does anyone know how I am able to force the file permissions to adhere to a 755 permission setting as well?

thanks in advance!

chicken or egg first?
A. Clay Stephenson
Acclaimed Contributor

Re: umask command


I hope you meant a umask setting of 022 or your examples don't work.

Directories are created with a default mode of 777 and when xor'ed with a umask of 022 give 755 permissions.

Regular files are created with a default mode of 666 and when xor'ed with a umask of 022 five 644 permissions.

In order to create regular files with permissions of 755 you must using a creation mode of 0777 which would xor with 0022 umask to yield 0755. This is easy to do if creating the file in C but in the shell you would need a chmod after the file is created.

Regards, Clay
If it ain't broke, I can fix that.