why newly created file permission always 644...umask issue
Hello There,
i have some confusion about umask.What i have learned by this time.... with umaks value i can control the permission of new files. Like if i set umaks value to 077 for an user then that users newly created file permission would be (777-077) = 700. I use /etc/bashrc file Code:
# Even for non-interactive, non-login shells. Code:
[john@pc5 ~]$ touch file I don't get it.How can I make this work? Thank You. |
Quote:
|
That's weird, it works for me (Ubuntu 9.something, bash).
Here's me testing several different umasks: Code:
dhm@voodoo$ umask HTH |
Quote:
but a as a root if i want to set a default umask value for one of my user then how should i proceed.... Is it even possible? |
eboy98, why don't you (as a test) just set the umask in your conditional to something like 026 instead of 077 and then check whether user john's files get created by touch as 640 (666-026) and his directories by mkdir as 751 (777-026).
If they do, then you know your current approach already works. |
When a new file is created it is created with 666 permissions. The umask value is then ANDed with these permissions to determine what the permissions will be set to.
In your scripts, always precede the mask values with 0 because they are octal numbers. Inside $((..)) or [[ .. ]], an expression may be interpreted as an integer. If you use 177 instead of 0177, it might not be what you think. > um=$((0177)) > echo $um 127 > um=$((177)) > printf "%o\n" $um 261 |
You could use the symbolic notation instead; it sets what you ask for
Quote:
|
Quote:
I am using rhel5 at VirtualBox. Code:
[john@pc5 ~]$ umask |
Quote:
What do you get if you run that same exact test with the 077 umask value? |
Quote:
Yes it also changed.....that you were expecting,mentioned at the earlier post. Here is the output: Code:
[john@pc5 ~]$ umask |
Quote:
|
If you enter "umask 589", the argument is rejected and the umask isn't changed. The argument must be an octal number and be a legal value.
I just use bash, and umask is a shell builtin function. |
Quote:
|
I wouldn't.
Quote:
|
What I was referring to in that quote was that 589 would be the resulting file permission mode for a 077 umask value. Since we know a file can't have 589 permissions, a different mode for files is being used when a umask 077 value is specified. Based on the above posts, that mode is 600, but how (or from where) is that value automatically computed (or selected)?
|
All times are GMT -5. The time now is 12:31 PM. |