Understanding the chmod calculator — concept and principle
On Linux, macOS and other Unix-like systems, every file and directory has permission bits that say who can read, write and execute it. This calculator converts between the octal form used with the chmod command (such as 755) and the symbolic form shown by ls -l (such as rwxr-xr-x), explains each permission in plain words and gives ready-to-use chmod commands.
How it is calculated
Each octal digit = read (4) + write (2) + execute (1)
Digit order: owner (user), group, others
Optional leading digit: setuid 4000, setgid 2000, sticky 1000
ls -l shows s or S in an execute position for set-ID bits (S if execute is off) and t or T for the sticky bit
Examples: 7 = rwx, 6 = rw-, 5 = r-x, 4 = r--, 0 = ---
The principle
Permissions are stored as bits, and octal is a compact way to write groups of three bits. Each digit packs read, write and execute for one class of user, so 755 means the owner may do everything while group members and others may read and execute. On directories the same bits mean something slightly different: read lets you list names, write (with execute) lets you create, delete and rename entries, and execute lets you enter the directory and reach files inside. Special bits change how programs run (set-ID) or protect files in shared directories (sticky).
Worked example
Default inputs: mode 755, applied to a file.
- 7 = 4 + 2 + 1 = rwx for the owner; 5 = 4 + 1 = r-x for group and others.
- Octal mode = 0755; symbolic = rwxr-xr-x.
- Owner: read it, change it, run it.
- Group and others: read it, run it.
- Special bits: no special bits; commands chmod 755 and chmod u=rwx,g=rx,o=rx.
How to read the result
755 is common for programs and directories that everyone may use but only the owner may change. 644 (rw-r--r--) is common for ordinary files. 600 (rw-------) keeps a file private, which some tools require for private keys. Avoid 777, which lets anyone change the file; it is rarely needed and can be a security risk.
Common mistakes
- Using 777 to fix a permission error instead of finding the right owner or group.
- Forgetting that a directory needs execute permission to be entered.
- Confusing the order: owner first, then group, then others.
- Setting setuid on scripts, which many systems ignore for security reasons.
Frequently asked questions
What does chmod 644 mean?
Owner read and write; group and others read only (rw-r--r--).
Why can't I enter a directory I can read?
Entering requires the execute (search) permission.
What is the sticky bit?
On a directory, it stops users from deleting or renaming other users' files, as in /tmp.
What does a capital S mean in ls -l?
A set-ID bit is set but execute is not.
Sources: The Open Group Base Specifications Issue 7 (POSIX.1-2008, IEEE Std 1003.1), chmod and ls utilities