Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path
Chmod Calculator
A Unix file-permission calculator. Toggle read, write and execute for owner, group and others to get the octal mode (like 755) and the symbolic string (rwxr-xr-x), or type an octal number to see exactly which permissions it grants. Explains what each bit means and the common modes to reach for.
chmod 755 file| read (4) | write (2) | execute (1) | |
|---|---|---|---|
| Owner | |||
| Group | |||
| Others |
Unix permissions look cryptic, but they are nine on-off switches written two ways. Every file has three classes of user, the owner, the group and others, and each class gets three switches: read, write and execute. Click the switches and the tool writes the octal mode, the symbolic string and the matching chmod command. Type an octal mode and it sets the switches for you.
What it computes
Within a class, read is worth 4, write 2 and execute 1, and the class digit is the sum of the switches that are on. Each digit holds exactly three bits, so the mode is written in octal, base 8, always in the order owner, group, others. These are the nine POSIX permission bits, from 0400 for owner read down to 0001 for others execute.
digit = 4 × read + 2 × write + 1 × execute each switch is 1 or 0
mode = owner digit, group digit, others digit
symbolic = r or -, w or -, x or - for each class in turn
command = chmod mode file
Decoding runs the other way: each digit is split back into its three bits by testing it against 4, 2 and 1. Characters that are not digits from 0 to 7 are ignored, and a short entry is padded with leading zeros, the same way chmod reads it, so 64 means 064, or ---rw-r--.
A worked example
The calculator opens on 755. The owner row has all three switches on; the group and others rows have read and execute on.
| Class | Switches on | Sum | Digit | Symbolic |
|---|---|---|---|---|
| Owner | read, write, execute | 4 + 2 + 1 | 7 | rwx |
| Group | read, execute | 4 + 1 | 5 | r-x |
| Others | read, execute | 4 + 1 | 5 | r-x |
755 rwxr-xr-x chmod 755 file
As one number, octal 755 is 7 × 64 + 5 × 8 + 5 = 493 in decimal, which is why code that sets a mode needs an octal prefix, as in 0o755 in Python or 0755 in C. Decoding works digit by digit: type 640 and 6 = 4 + 2 gives rw-, 4 gives r-- and 0 gives ---, so the mode reads rw-r-----.
Assumptions and limits
- Nine bits only. Setuid, setgid and the sticky bit form a fourth, leading digit, as in 4755 or 1777, which this calculator does not set. The field takes three digits, so for a four-digit mode enter only the last three.
- No file-type character.
ls -lprints one more character first,-for a file ordfor a directory, and may append+when an access control list exists. - Execute means two things. On a file it allows running it. On a directory it allows entering it and reaching files inside by name, while read only lists the names.
- Other layers can override the bits. ACLs, a filesystem mounted
noexec, SELinux or AppArmor policy, and the root user, who bypasses read and write checks, all sit outside the mode. - The command is a template. Replace
filewith your path.chmod -R 755also makes every file executable;chmod -R u=rwX,go=rXis safer, because a capital X adds execute only to directories and to files that already have it.
How to use the result
Start from the least access a file needs and add only what a real user or process requires.
- 644 for ordinary files and 755 for directories and scripts. These are what the common umask
022produces, since it removes write for group and others from the 666 and 777 that new files and directories request. - 600 for secrets such as SSH private keys and
.envfiles, and 700 for~/.ssh. OpenSSH refuses a private key that grants the group or others any permission. - 640 or 750 when a service account should read a file through its group, instead of opening it to everyone.
- 777 is almost never right, because anyone on the machine can change or replace the file. Shared scratch directories such as
/tmpuse 1777, with the sticky bit. - Fix ownership before widening the mode. When a process cannot write,
chownorchgrpto the right user or group is usually the real fix.
When to use it, and when not
Use it to read or write a mode quickly: decoding -rw-r----- from ls -l, checking the chmod line in a Dockerfile, or choosing the mode for a deploy script. It is also a quick check of the number you put in code, where a mode must be written as an octal literal.
Do not use it to answer “can this user open this file?” That depends on who owns the file, which groups the user is in, every directory on the path, ACLs and security modules, and a mode shows none of them. Test as that user instead, for example sudo -u www-data cat path, or run namei -l path, which prints the mode and owner of every directory on the way down.
Trade-offs and limits
The mode is one input to an access check. The calculator shows it in isolation, which misleads in four ways:
| Not modelled | What really happens | Example |
|---|---|---|
| Which class applies | The kernel picks one class, owner first, then group, then others, and checks only that class’s bits. Classes never add up. | At 604 a group member is refused, although others may read. |
| The directory | Deleting or renaming a file needs write and execute on its directory, not on the file. | A 444 file in a 777 directory can be deleted by anyone. |
| The path | Every directory above the file needs execute for you. | A 644 file inside a 700 home directory is unreadable to other users. |
| Special bits already set | GNU chmod keeps a directory’s setuid and setgid bits when given a three-digit mode. | chmod 755 on a 2775 directory leaves 2755; chmod 00755 clears it. |
Common mistakes
- Passing a decimal number to a chmod call.
os.chmod(path, 755)in Python sends decimal 755, which is octal 1363:-wxrw--wxplus the sticky bit, so the owner loses read. Write0o755. - Giving the group more than the owner. At 070 the owner is locked out even when they belong to the file’s group, because the owner class matches first. Only the owner or root can change the mode back.
- Protecting the file and not its directory.
chmod 400stops edits in place, but anyone with write on the directory can delete the file and create a new one with the same name. - Fixing the key and forgetting the path. With
StrictModeson, the default, sshd refusesauthorized_keyswhen the home directory or~/.sshis writable by group or others. A home directory at 775 breaks key login however correct the key file is. - Reaching for 777 on a container volume. A permission error on a mounted volume usually means the process runs under a different UID from the files’ owner. Match the UID or
chownthe volume, and keep 755 or 750.
Check yourself
A shell has umask 027. What modes do a new file and a new directory get?
Files request 666 and directories 777, and the umask removes its bits: 666 AND NOT 027 = 640, rw-r-----, and 777 AND NOT 027 = 750, rwxr-x---. The group can read and enter; others get nothing.
A file is 604. Can a member of the file’s group, who is not its owner, read it?
No. Group membership selects the group digit, 0, and the others digit is never consulted. A user outside the group can read the file; a group member cannot.
/srv/share is 711 and holds report.txt at 644. What can another user do?
Others have only execute on the directory, so ls /srv/share fails, but cat /srv/share/report.txt works for anyone who knows the name: execute lets them reach the file and its others digit, 4, lets them read it. At 744 it is the reverse: they can list the names but open nothing.
What mode does os.chmod(path, 600) set, without the 0o prefix?
Decimal 600 is octal 1130: the sticky bit plus --x-wx---, owner execute only and group write and execute. The private file is now unreadable by its owner. 0o600, decimal 384, is what was meant.
How it works
- Toggle r/w/x for owner, group and others to get the octal and symbolic mode.
- Type an octal mode (e.g. 640) to decode it back to rwx.
- Presets for the common modes: 644, 755, 600 and 777.
- Read = 4, write = 2, execute = 1, summed per class.
Frequently asked questions
How does the octal permission number work?
Each of the three permission classes, owner, group and others, gets one octal digit built from three bits: read is 4, write is 2 and execute is 1. You add the ones you want, so read, write and execute make 7, read and execute make 5, read and write make 6, and read only is 4. So 755 means the owner has 7, rwx, while group and others have 5, r-x. The three digits, left to right, are always owner, group, others.
What is the difference between chmod 644 and 755?
644, or rw-r--r--, is the usual mode for regular files: the owner can read and write, and everyone else can only read. 755, or rwxr-xr-x, is the usual mode for directories and executables: the owner can read, write and execute, while others can read and execute but not modify. The only difference is the execute bit for all three classes. On a file it means run this program, and on a directory it means you may enter it.
What does the execute bit mean on a directory?
On a directory, execute is the search permission: it lets you enter the directory and reach the files inside by name. Read on a directory only lets you list the names. Without execute you cannot cd into it or open a file inside, even one whose name you know and whose own mode allows reading. That is why directories are almost always 755, 750 or 700 rather than 644: removing execute from a directory locks people out of everything within it.
What about setuid, setgid and the sticky bit?
They form a fourth, leading octal digit, as in 4755, 2755 or 1777, which this calculator does not set. Setuid, worth 4, makes an executable run with its owner as the user. Setgid, worth 2, runs it with the file group or, on a directory, makes new files inherit the directory group. The sticky bit, worth 1, stops users deleting each other’s files in a shared directory such as /tmp. Setuid on the wrong program is a classic privilege escalation risk.
What permissions should an SSH private key have?
Use 600, read and write for the owner only, or 400 if you want it read-only. The ~/.ssh directory itself should be 700. OpenSSH checks this: if a private key file grants any permission to the group or to others, it prints a warning that the key is unprotected and refuses to use it. The same 600 mode is a sensible default for any secret on disk, such as a .env file, a token file or a database password file.
Is chmod 777 ever a good idea?
Almost never. 777, or rwxrwxrwx, lets every user and every process on the machine change, replace or delete the file, which turns any compromised account into a way to tamper with it. It usually appears when a permission error is fixed by opening everything up. The better fix is ownership: chown the file to the user that needs it, or give a shared group access with 770 or 775. Shared scratch directories such as /tmp use 1777, where the sticky bit protects each user’s files.