Chmod Calculator
Tick the boxes to build a permission value, or type an octal number or a symbolic string to see exactly what it grants. Everything runs in your browser.
| Who | Read (4) | Write (2) | Execute (1) |
|---|---|---|---|
| Owner | |||
| Group | |||
| Others |
Command
Common values: 400 · 600 · 644 · 664 · 666 · 700 · 750 · 755 · 775 · 777 · 1777 · 2775 · 4755 · all values
How the numbers work
Each of the three permissions has a value: read is 4, write is 2 and execute is 1. Add together the ones you want and you get a single digit from 0 to 7. Do that three times — once for the file's owner, once for its group, and once for everyone else — and you have the familiar three-digit octal value.
So 644 is 4+2 for the owner (read and write), 4 for the group (read only) and 4 for everyone else (read only). 755 is 4+2+1 for the owner and 4+1 for the other two. Because each digit is three bits, octal maps onto the permission bits exactly, which is why permissions are written in base 8 rather than base 10.
What execute means on a directory
This is the part that catches people out. On a file, x means the file can be run as a program. On a directory it means something quite different: it grants the right to traverse into the directory and access things inside it by name.
The practical consequence is that a directory with r but no x lets you list the names in it but not read any of the files, while a directory with x but no r lets you open a file whose name you already know but not discover what is there. This is why directories are almost always 755 and files 644 — the same permission digit means different things depending on what it is applied to.
The two you should be careful with
777 grants write access to every user on the system. It is a common piece of bad advice for fixing a permissions problem, and it usually works, in the same sense that removing the lock fixes a stuck door. If a web server cannot write to a directory, the fix is to change the directory's owner or group to the server's user, not to open it to everyone.
666 on a file has the same problem without even the excuse of being executable. If you find yourself reaching for either, the question to ask is which user actually needs the access, and then grant it to that user.
The fourth digit
Permissions can carry a fourth leading digit that most people never set deliberately:
| Bit | Value | What it does |
|---|---|---|
| setuid | 4000 | An executable runs as its owner rather than as the user who ran it. This is how passwd can edit a file only root may write. |
| setgid | 2000 | On an executable, it runs with the file's group. On a directory, new files inside inherit that directory's group — genuinely useful for shared project folders. |
| sticky | 1000 | In a world-writable directory, only a file's owner may delete it. This is what stops one user removing another's files from /tmp. |
In symbolic output these replace the execute character: an uppercase S or T means the special bit is set but execute is not, which is almost always a mistake.
Symbolic mode
chmod also accepts changes rather than absolute values, which is safer when you only want to adjust one thing:
| Command | Effect |
|---|---|
chmod +x script.sh | Add execute for everyone, subject to the umask |
chmod u+x script.sh | Add execute for the owner only |
chmod go-w file | Remove write from group and others, leaving everything else alone |
chmod a=r file | Set everyone to read only, clearing write and execute |
chmod -R u+rwX dir | Recursive; capital X adds execute only to directories and files that already have it somewhere |
That capital X is worth remembering. chmod -R 755 on a source tree marks every file executable, which is wrong for almost all of them; chmod -R u+rwX does the sensible thing instead.
Frequently asked questions
What is chmod 755?
Read, write and execute for the owner, and read and execute for the group and everyone else — written rwxr-xr-x. It is the normal setting for directories and for scripts that need to be runnable.
What is chmod 644?
Read and write for the owner, read only for the group and everyone else — rw-r--r--. This is the usual setting for ordinary files that are not meant to be executed.
Is chmod 777 safe?
No. It lets any user on the system modify the file or directory. It often makes a permissions error go away, which is why it gets recommended, but the correct fix is almost always to change the owner or group so the process that needs access has it.
What does the x bit do on a directory?
It grants the right to traverse the directory and reach the entries inside it by name. Without it, the directory cannot be entered even if you can list its contents, which is why directories need execute and ordinary files do not.
Why are permissions written in octal?
Each permission set is exactly three bits — read, write and execute — and one octal digit is exactly three bits. The mapping is one-to-one, which decimal would not give you.
What is the difference between chmod and chown?
chmod changes what the owner, the group and everyone else may do. chown changes who the owner and the group actually are. A permissions problem is often a chown problem.