What is the first digit in umask value?
The first digit 0 is not in use in your example. The umask reads from right to left and trailing zeros are ignored. It can however be used to set special permissions, such as sticky bit
, Set GUID
, Set UID
as shown below.
0755 —- None of the special bits set
1755 —- Sticky bit set
2755 —- SGID bit set
4755 —- SUID bit set
You are correct that a umask of 0022 the will mask a default 777 (directory) permission to become 755 on newly created directories.
The octal numbering works similar to the first three sets: user, group, world/other.
The read/write/execute rwx
values are represented in octal form with the corresponding values which can total a maximum of 7:
4 - Read
2 - Write
1 - Execute
So for 0755: 0 is ignored. 7 (4+2+1) equals read, write, and execute for the user
/owner. And 5 (4+1) equals read and execute for the group
, and the remaining 5 (also 4+1) gives read and execute permissions to other
/world.