76 / 102
Default Permissions
System calls to create new files and directories have default or base permissions:
- Directories: (octal)
0777
orrwxrwxrwx
. - Files: (octal)
0666
orrw-rw-rw-
.
The first octal digit is for special permissions. The next three are for user, group and others.
Before creating the file or directory, the base permissions are compared to a mask that will "mask out" permission bits to determine the final permissions for the object being created.
The calculation to determine the final permissions is to take the binary of the base permissions and perform a logical AND operation on the ones complement representation of the binary umask.
umask
- Display or set file creation mask.
The usual umask is 0022
, which results in 0755
for directories, and 0644
for regular files.
0 0 2 2 0 7 7 7 0 6 6 6 000000010010 000111111111 000110110110 111111111111 111111101101 111111101101 ------------ ------------ ------------ 111111101101 000111101101 000110100100 0 7 5 5 0 6 4 4