Unix and Linux permissions fit in three digits, and the maths behind them is simple but easy to forget. This chmod calculator lets you pick read, write and execute for the owner, group and others, adds an optional special bit, and gives the octal mode to type after chmod.
How the calculation works
- Each class (owner, group, others) gets a digit from 0 to 7: read counts 4, write counts 2, execute counts 1, and the digit is their sum.
- Mode = owner digit, group digit, others digit, written one after another. Owner read, write and execute with group and others read and execute is 7, 5, 5.
- Special bits add a leading digit: 4 for setuid, 2 for setgid and 1 for the sticky bit. A mode such as 1777 is a sticky shared directory.
- Command to apply the result: chmod 755 file, or chmod -R 755 folder to change a whole directory tree.
- Symbolic form: the same permissions can be written as letters, for example rwxr-xr-x for 755.
Example
A web server script should be readable and executable by everyone but changeable only by its owner. Owner: read 4 + write 2 + execute 1 = 7. Group: read 4 + execute 1 = 5. Others: read 4 + execute 1 = 5. The mode is 755, the command is chmod 755 script.sh, and the symbolic form is rwxr-xr-x.
Why it matters
Permission mistakes are among the most common causes of web server errors, failed deployments and security problems. Too tight, and a script will not run or a site shows a 403 error. Too loose, and any user or any compromised program can change your files. Building the mode from the three questions of who can read, write and run makes the right number obvious.
Good to know
The calculator covers the classic permission bits. Real systems add access control lists, file ownership, extended attributes and mandatory access control such as SELinux, which can allow or deny access regardless of the mode. Directories treat execute as the right to enter them, and write on a directory means the right to add or remove files. Use the least permissive mode that works, and keep private keys and configuration files at 600 or 400.
Related tools
The subnet calculator covers another everyday admin task, the password strength calculator shows how long a password would resist guessing and the hash collision calculator estimates the risk of duplicate identifiers.