UMask

From CSWiki
Jump to: navigation, search

UMask (short for user file creation mask) is a function which dictates the default file permissions of newly created files and folders.

[edit] Default UMask

By default on our servers, any new folders will be created with permissions of 700 (-rwx------), and any new files will be created with permissions of 600 (-rw-------). This insures that any files you create will not be accessible by others. This however causes a problem with creating files for your Personal Webpages, since these files must be accessible by others, so they can view them.

[edit] Determining UMask Value

In order to find out what to set your umask to, you have to think about the octal notation you want the files to be when they are created. Folders start with an octal notation of 777, and files with 666. You then subtract your umask value from these numbers to determine what the final value will be.

For example, if we set our umask to 0022, new folders will be created with permissions of 755 (777 - 022 = 755; -rwxr-xr-x), and new files will be created with permissions of 644 (666 - 022 = 644; -rw-r--r--).

[edit] UMask Command

[edit] Check Current Umask

You can check your current umask setting with the umask command:

$ umask
0077

[edit] Temporarily Change UMask

Your umask can be temporarily changed before creating new files, so that the files you create will have the proper permissions necessary for your project. This can be accomplished with the umask command:

$ umask 0022

Changing the umask this way is only temporary; your umask value will be reset to the default value the next time you log in.

[edit] Permanently Change UMask

You can also permanently change your umask value by editing your ~/.bashrc file, and adding a umask command to the end. Changing your default umask to 0022 can be accomplished with the following command:

$ echo "umask 0022" >> ~/.bashrc

The change will take effect the next time you log in. To remove the new umask, simply open your ~/.bashrc file with your favorite text editor and remove the umask line.

[edit] More Information

Personal tools