Practical developer guides

chmod and umask: creation masks and special bits

Compute creation permissions as bit masks and distinguish rwx modes from sticky, setuid and ACL behavior.

Nav Tools ·

Read the three rwx groups

The familiar three octal digits encode owner, group and other read/write/execute bits. Each bit is a permission, not a decimal score.

Use chmod Calculator to inspect an ordinary mode before reasoning about creation rules.

0640 → owner rw-, group r--, other ---

Apply umask as a bit operation

For ordinary creation without overriding default ACL effects, the requested mode is masked by the complement of umask. It is not arithmetic subtraction.

Programs commonly request 0666 for files and 0777 for directories, so one mask produces different results.

umask 0027:
file:      0666 & ~0027 → 0640
directory: 0777 & ~0027 → 0750

Separate special bits from rwx

A fourth octal digit can represent setuid, setgid and sticky bits. Their effects depend on file type and operating-system rules.

The site's three-digit calculator focuses on rwx and is not a full special-bit or ACL simulator.

Directory mode 1777 includes the sticky bit.
It is not equivalent to ordinary 0777.

Inspect the real access-control layers

ACLs, mount flags, parent-directory search permission and process identity can affect access beyond displayed rwx bits. umask does not retroactively modify old files.

Inspect the actual file and runtime identity when diagnosing permission denied. A correct octal conversion alone cannot establish access.

References

← Practical developer guides