I'm a little confused on umasking. The way I was shown to do it manually is to take whatever number the umask is, say 123, turn that into binary for the permissions.

001010011

flip the bits

110101100

and then take away executability

110100100

thus I get rw-r--r--

but when I enter umask 123 myfile into the terminal and then do a ls -l myfile, I see permissions of

-r--rw-rw-

Am I missing something?

Thanks.

Hey There,

Your pretty much good, but I just use octals:

so generic file =
644
110 100 100

umask
123
001 010 011

take the bitwise NOT of the umask (just flip the bits)
110 101 100

and the bitwise AND of that and your original perms (only columns with 1 and 1 = 1, 0 and 0 & 1 and 0 both = 0

110 100 100
110 101 100 =

110 100 100 =
6 4 4

You'll get the result you probably want if you remove the system default 022 umask (since a new files real default perms are 666 and the 022 makes them 644 and probably skews what you're expecting)

So you're umask is actually working correctly - let me know if further explanation is required or if this doesn't make any sense - once you start to think it, it's harder to explain ;)

Best wishes,

Mike

No I got it, thanks!

:)

Great :)

Best wishes,

Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.