mode argument used in both the
methods is a numeric bitmask created using a logical OR of the following
|read by owner|
|write by owner|
|execute/search by owner|
|read by group|
|write by group|
|execute/search by group|
|read by others|
|write by others|
|execute/search by others|
An easier method of constructing the
mode is to use a sequence of three
octal digits (e.g.
765). The left-most digit (
7 in the example), specifies
the permissions for the file owner. The middle digit (
6 in the example),
specifies permissions for the group. The right-most digit (
5 in the example),
specifies the permissions for others.
|read, write, and execute|
|read and write|
|read and execute|
|write and execute|
For example, the octal value
- The owner may read, write, and execute the file.
- The group may read and write the file.
- Others may read and execute the file.
When using raw numbers where file modes are expected, any value larger than
0o777 may result in platform-specific behaviors that are not supported to work
consistently. Therefore constants like
not exposed in
Caveats: on Windows only the write permission can be changed, and the distinction among the permissions of group, owner, or others is not implemented.