How to Calculate Umask


The umask enviromental variable sets the file permission for all files and directories in Linux and Unix operating systems. The variable works as a mask, and subtracts execute, write and read permissions from specified files and directories. The default permissions are 666 -- read and write for all users -- for files, and 777 -- read, write, execute for all users -- for directories. Since the default values are inherently insecure, use the umask variable to create a more secure environment.

  • Open a Terminal window. Type the command umask to determine the umask value, which is usually around “022."

  • Subtract the umask value from “666” for files and “777” for directories. For instance:

    666 - 022 = 644
    777 - 022 = 755

  • Determine the file permissions from the resulting values. The values are based on the octal code for permissions which are “4” for read permissions, “2” for write permissions and “1” for execute permissions. The value “644” for files gives the owner of the file read and write permissions while the group and others have only read permissions. The value 755 gives the owner of the directory read, write and execute permissions while the group and others have only read and execute permissions.

  • Type exit to close the terminal session.

Tips & Warnings

  • The "chmod" command overrides the values for umask files and directories.


Promoted By Zergnet


You May Also Like

Related Searches

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!