Using the command "umask"

Usage: umask [xxx]

At first remember that this command do NOT change the environment but is effective only in the subshell where you type it in.

Just typing in "umask" will give you the actual value.
Example:
boaz % umask 22

Meaning of "xxx"

At first translate the given octal number nnn into binary.
Example: 22 --> 000 010 010

Then do the same with the file permission that you see using the command "ls -l ":
Example: ls -l ifh-dhcp_conf
-rw-r--r-- 1 ballisti ifh 2940 Jul 8 10:39 ifh-dhcp_conf

Forget about the first hyphen which shown the type of the file and convert the symbols in binary numbers:
rw-r--r-- --> 110 100 100

Now let suppose, that you want to take away the "read" for "others". For this reason you need a mask which look like this:
000 000 100

But let us suppose, that you want to have "---" as permission for others. Thus to reach this goal the mask must be 000 000 111.
The ones in the mask will "take away" the corresponding bit of the file permission. Thus a mask as the last one shown will leave unchanged all the bits for "user" and "group" but delete (i.e. put = 0) all the bits for "others" if any.

It is like a NOR gatter:
110 100 100 actual permission
000 010 111 mask
110 100 000 result: new permission

The value in octal of such a mask is 7. If you also want to take away the write bit of the group permission, then you will need a mask like
000 010 111 which is 027.

Thus the command "umask 027" will do this job.

Please, see "man umask"

Back to Home Page our Laboratory