umask and How It Works

The umask is a value that determines the default permission settings assigned when new files and directories are created.Each UNIX system has a default umask value; each user can change his or her own umask value (and usually does so at login time in a .cshrc, .login, or .profile file); each process can also examine or alter its umask value with the umask command.

umask is an inherited feature. If a process sets a particular umask, its children will inherit the same umask value.Here’s how umask works. Numerically, it specifies which permissions are not granted by default when a file or directory is created. For example, a user’s umask is set to 027. The umask 027 is broken down into 0, 2, and 7. The 0 means that the user will have all permissions; the 2 means that group will not have write (2) permissions; the 7 means that other will not have execute (1), write (2), or read (4) permissions.






Another way to think about umask is to subtract each of its digits from 7; the resulting digits are the permission set up for a file or directory that is created while that umask is in effect.

In addition to being set numerically, a umask can also be set symbolically, with options similar to chmod’s symbolic syntax. For example

umask u+rwx,g+rx,o-a …is the same as: umask 027
umask u+rw,g+r,o+r …is the same as: umask 133


Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA *