Understanding Umask Settings: Why is 027 the Correct Answer?

0
30
Asked By CuriousCoder42 On

I'm trying to figure out the correct umask setting for a scenario where the file owner has all permissions, the group has read permissions, and others have no permissions. I was told that the umask of 027 fits this, but I'm confused about how that works. If the maximum permission for files is 666, how can the umask be subtracted from that to give a proper result? Specifically, how do we subtract 7 from 6?

1 Answer

Answered By TechGuru88 On

Actually, the maximum permission you’re talking about isn't 666; it's 7. This number comes from the read (4), write (2), and execute (1) permissions combined. So, when you apply a umask of 027 to permissions starting at 666, you're not subtracting but rather 'masking' certain bits. If you start with 666 and apply 027, it results in 640.

CodeNinja99 -

But if we consider 777 as max, then shouldn’t the mask be 037 instead? The answer suggests 027, which feels incorrect.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.