Why doesn't "umask" work here?
I want to set umask to 343
.
I calculated that the permissions of the newly created files should be: -wx-w--wx
but I get: -r---w-r--
My terminal:
meliwex@reverse-proxy:~/testfolder$ ls -l
total 0
meliwex@reverse-proxy:~/testfolder$ umask 343
meliwex@reverse-proxy:~/testfolder$ touch file1
meliwex@reverse-proxy:~/testfolder$ ls -l
total 0
-r---w-r-- 1 meliwex meliwex 0 Nov 6 09:13 file1
meliwex@reverse-proxy:~/testfolder$ umask
0343
meliwex@reverse-proxy:~/testfolder$
I set this umask just for testing purposes.
Solution 1:
I'm not sure how you calculated that, but a mask of 3 (011 in binary) masks the write and execute bits (the second and third bits respectively). A mask of 4 (100 in binary) masks the read bit. Therefore a mask of 0343 will result in read permissions being set for user and other, and write permission being set for group (as the execute bit is masked for files anyway). And that's what you got.