Sunday, October 4, 2015

What is umask ?



                     umask, as the man page says, stands for User file creation mask .The umask controls what permissions are given to newly created file system objects such as files and directories.

Default permission

The UMASK value for a folder is and  777  means (rwxrwxrwx)

The UMASK value for a file is 666 means (rw-rw-rw)

Most of the linux distribution umask is set to 0022.

                    umask is by default displayed in Octal form, and hence the first 0 in the umask value is the indication for octal value. So, the actual umask is 022. This value together with the default file value(666) decides the final permission to be given to the file.

                    Assume we create a file say "file1". The permissions given for this file will be the result coming from the substraction of the umask from the default value :

  Default : 666
  umask  : 022
---------------
   Result :   644

Same is applied to folder :

  Default : 777
  umask  : 002
---------------
   Result :  775

              Files have 666  because only scripts and binaries should have execute permissions, normal and regular files should have just read and write permissions.

              Directories require execute permissions for viewing the contents in it, so they can have 777 as permissions.

How to see default UMASK?

#umask       

The option -S gives in more readable format.

#umask –S
U=rwx,g=rwx,o=rw

4. How to set this umask permanently for a user?

#grep umask /etc/bashrc /etc/profile

For local users you can set the umask to the user home directory,edit the ~/.bashrc and insert the umask value

To global effect edit the /etc/profile file



No comments:

Post a Comment