On Wed, 17 Sep 2008, Tim Wilson wrote:

> I've never been able to wrap my head around umask either.

My understanding (which seems to be working for me)...

umask is used to determine default file permissions.  File permissions can 
be written in terms of letters r, w, x (for permission to read, write or 
execute the file, respectively), but the numbers 4, 2, 1 can be used 
instead of r, w, x, respectively and those numbers can be summed.  So the 
number 6 means read and write, 5 means read and execute, etc.

The other aspect of permissions is *who* has them.  We use order to 
designate this: first is owner, second is group and third is "other" 
(which means everyone, really).  So the permissions 750 means that owner 
can read, write or execute, group members can read and execute, but others 
can not do anything.  The most common permissions seem to be 755 (for 
directories or executable files) and 644 for non executable files.

Now to umask.  The umask is a string of three digits that are subtracted 
away from 777 (directories and executables) or 666 (other files) to give 
the default permissions for a newly created file.  So the permissions for 
a new directory or file could be written like so:

777-umask
666-umask

If the umask is 022, and it often is, this would yield the usual 755 and 
644 permissions.  I think a negative number is treated as zero so that a 
umask of 027 yields 640 for new regular files.

I'm sure there is a lot more to know, but that is my simple-minded 
approach that works most of the time.

Mike