umask is set to controld permissions (set by the server administrator) for newly created files & directories. That is created by other users on the system.When you set a umask for example 0666 then you need to minus this 0666 with 0777 for a directory and 0666 for files.
And then you get a system umask of 0111. 0666 - 0777 = 0111 for your directoryes, and 0555 for your files.The directory number to minus your umask with is 0777 and
the files number to minus your umask with is 0666Another example. Directory.
0222 - 0777 = 0555
0274 - 0777 = 0503and Files.
0222 - 0666 = 0444
0264 - 0666 = 0402a umask 0000 is = 0777 = all permissions
Read
Write
Executea umask 0111 is = 0666 = Read + WriteWhen looking at permissions you seex xxx xxx xxx
x = Type (directory, file, special files e.c.t)
#1 xxx = users
#2 xxx = groups
#3 xxx = othersThese 3 x then has a value.
4 2 1 4 2 1 4 2 1
X X X X X X X X X
R W X R W X R W XR = Read
W = Write
X = Executethe value 7 is all the numbers in a XXX group put together 4+2+1 = 7 = all permissions.If it was 0752 then it would be
#1 Users = all permissions 4+2+1 = 7
#2 Groups = Write + Execute 4+1 = 5
#3 Others = Write 2 = 2Hope this helpsADDED:
For the first digit in a umask. Its a sticky bit.(4)xxx sets the SUID
(2)xxx sets the SGID
(1)xxx sets the sticky bit
(6)xxx sets both the SUID and SGID
(7)xxx sets all three The sticky bit does if more people (a group) has 0777 permissions to a file, then they can delete the file also. If i want
them to have all permissions but not able to delete the file i can set a sticky bit 1777 and then its only the owner of the file who can delete it. The group can still see the file, open it, change its contents. They can do all that the permissions alow them to EXECT deleting the file.And then the permissions would look like this rwx-rwx-rwt the t reporsents the sticky bit. A umask of 1777
“fmask=177,dmask=077” “Root has read/write access, users have no access”
“fmask=333,dmask=222” “Everyone has read only access”
“fmask=133,dmask=022” “Everyone has read access, but only root can write”
“fmask=111,dmask=000” “All users can read/write to any file”
References : http://ubuntuforums.org/showthread.php?t=1453342