Understanding Umask Settings: Why is 027 the Correct Answer?
Asked by
CuriousCoder42
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?
Answers
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.
Reply to this answer
Add your answer
Answers are reviewed before publication.
CodeNinja99: But if we consider 777 as max, then shouldnโt the mask be 037 instead? The answer suggests 027, which feels incorrect.