Questions tagged [umask]

Mask that controls which file permissions are set for files and directories when they are created. It also refers to a function that sets the mask, and to the mask itself, which is formally known as the file mode creation mask.

Introduction

When a user creates a file or a directory under GNU/Linux or another Unix-like operating system, the default set of permissions are set by the umask command.

Set up the default umask

Usually the umask is set in the file:

 /etc/profile

or for bash shell:

~/.bashrc 
~/.bash_profile

for ksh/bash:

 ~/.profile 

for csh:

~/.cshrc 

for defining the user's environment at login:

~/.login

and it set with adding something like in the files:

umask 022

How is the umask calculated ?

The umask command uses octal values for determining the permissions of the files and directories. The default permissions for a file are calculated by subtracting the value of 666 like:

666 - 022 = 644  

This means the file permissions would be (rw-r--r--)

For directories the default permissions are calculated as follows:

777 - 022 = 755

This translates to base directory permissions (drwx-rw-rw-)

For more information on umask type in shell:

$ man umask

Reference

Wikipedia entry about umask

184 questions
21
votes
1 answer

How is umask calculated in Linux?

So I know umask can restrict privileged users, using this format umask ugo. I understand that the read = 4, write = 2, and exec = 1. However, when I type umask, it returns 4 digits which is 0022 or 0073. I have no understanding of how does this work…
Braiam
  • 35,991
20
votes
2 answers

How to check umask for all users under Linux?

Under AIX I can check the umask for all users with: cut -d : -f 1 /etc/passwd | while read ONELINE; do lsuser -a umask "$ONELINE"; done But how can I check the umask setting for all users under Linux? (su to every user and then umask command? Are…
gasko peter
  • 5,514
16
votes
2 answers

What is the first digit in umask value?

If I understand correctly file permissions have an associated 3 digit number which specify read/write/execute permission. The umask value is a default 'mask' which is subtracted from the default value. So for a umask value of 0022 the default value…
7
votes
2 answers

Different Umask for Directories and Files

How can I set up a different umask for directories then files? I need dirs with umask 003 and files with umask 117
Luigi T.
  • 528
2
votes
1 answer

Leading zero in umask 0022

How can I change leading zero in umask 0022? Can it be changed? I searched the usual methods for information and my local system was of little help. $ man umask No manual entry for umask $ umask --help bash: umask: --: invalid option umask:…
MikeD
  • 810
2
votes
1 answer

Where does the value that umask is applied to come from

I'm trying to understand umask properly. If I set umask to 0000 and then create a file I get the following permissions: -rw-rw-rw- I presume that this value (or set of permissions) is what the umask mask is applied to. What decides what this…
handles
  • 195
1
vote
1 answer

Is a file creation mask setted by a given shell's umask is typically unique to the operating system entirely or just to that given shell?

Is a file creation mask setted by a given shell's umask is typically unique to the operating system entirely or just to that given shell? For example, if I change the file creation mask (umask's mask/bitmask) in Bash will it change only for Bash or…
user149572
1
vote
1 answer

umask in /etc/profile and /etc/login.defs

I don't understand how umask works in these two files: my machine doesn't use pam_umask module. If I change user and create a new file/directory, the umask used is taken from /etc/profile (the umask in /etc/login.defs is unused). Which is the…
andrew
  • 11
1
vote
1 answer

How to permanently change umask value from 0002 to 0022?

My current umask value is 0002 $ umask 0002 $ I want to permanently change it to 0022 How can I do so?
Sonevol
  • 295
0
votes
0 answers

Umask for root and other system users

If I am not wrong, this is how umask is calculated. for dir, 777 - 022(root's umask value) = 755. for file, 666 - 022(root's umask value) = 644. Now, where this umask value is defined? Is it the /etc/bashrc file?. If so, then what is the file…
Gokul
  • 1,071
0
votes
1 answer

Linux Bible 10th Edition: are permissions calculated right with umask?

I read "Linux Bible 10th Edition", chapter 4: Becoming a Linux Power User, at 109 page. Second paragraph: $ umask 0002 If you ignore the leading zero for the moment, the umask value masks what is considered to be fully opened permissions for a…
CoderDesu
  • 145
0
votes
0 answers

what is the significance of the ACL value being a complement of UMASK value?

From the description section of man 2 umask command, it says For example, the following default ACL is equivalent to a umask of 022: u::rwx,g::r-x,o::r-x What's the significance of having another value which is a complement of UMASK instead of…
0
votes
2 answers

Is the umask function a kernel function?

I assumed the umask() function is a: shell function containing a variable commonly referred to as file creation mask but I was wrong because umask() is not a shell function and doesn't contain such variable. If the umask() function is not a…
user149572