I'm trying to figure out the correct umask settings based on the following requirements: the owner should have all permissions, the group should have read permissions, and others should have no permissions. I came across the umask value of 027 and I'm confused about how this works. It was mentioned that the maximum permission is 666 for files, but I'm not sure how we subtract 7 from it since umask is supposed to mask out permissions. Can someone clarify this?
2 Answers
You're right; it's all about understanding binary here. Each permission can be represented in binary rather than in decimal. For instance, a file's default permissions (666) are shown as 110 110 110 in binary. Applying a umask of 027 (which is 000 010 111 in binary) will turn off some of those bits. So the result would be adjusted permissions of 640 for files and 750 for directories.
Actually, the maximum permission is represented as 7, not 666. When you break it down: executable = 1, write = 2, read = 4, so all permissions combined equal 7. Therefore, when we apply a umask, we're modifying the maximum permissions, not subtracting directly from 666. If you have a umask of 027, it masks out some permissions, resulting in permissions like 640 instead of 666.
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures