The umask(2) Function and umask Bits

When new files and directories are created, the designer of the program must decide which permissions to use. These are usually specified as quite liberal permissions. Sometimes greater security is required when you do not want to give away certain permissions to the group or to the world.

Permission Bits

Just by way of review, the permission bit scheme will be presented. Not everyone is used to working with permissions in the octal form, which is the way umask is discussed for convenience.

The data type used for permission bits in modern UNIX systems is the mode_t data type. Under older versions of UNIX, it was the int data type. The permission bits are laid out in three groups:

rwx rwx rwx

Each of the ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.