A chmod calculator turns file permissions into the octal number that the chmod command takes, and turns a number such as 755 back into letters. Pick read, write and execute for the owner, the group and other users, add the special bits if you need them, and you get the number, the letters, the way that ls shows them and the command to type. It works the other way too. It runs in your browser, and it never touches a file.
How to use the chmod calculator
- Choose permissions to number or number to permissions.
- Pick the permission for the owner, the group and others, and the special bits if any. Or type the octal mode.
- Press Calculate.
- Copy the command and run it on your own system.
What chmod does
The Wikipedia article on chmod describes it as a shell command for changing access permissions and special mode flags of files, including special files such as directories. Its name is short for change mode, where mode means the permissions and flags together. It adds that changing permissions is only allowed for the superuser and for the owner of a file.[1] Most commands accept either a single octal value, which sets all the mode bits of each file, or a list of symbolic specifiers, which describes how to change the bits that are already set.[1] The calculator gives you both forms.
How the octal number works
With a numeric argument, the page says that chmod treats it as an octal number and replaces all of the mode bits of each file. There are twelve standard mode bits: three special bits, and three permission groups for the user, the group and other users, each of three bits for read, write and execute. Since an octal digit holds three bits, the twelve bits fit in four octal digits, and the leading zeros may be left out.[1] In practice three digits are common, because the special modes are rarely used.[1]
Each permission has a value: read is 4, write is 2 and execute is 1. A digit is the sum of the permissions that you give.[1] So 7 means 4 + 2 + 1, which is read, write and execute; 6 is read and write; 5 is read and execute; 4 is read only; and 0 is nothing. The page's own example is the value 754, which gives the user class read, write and execute, the group class read and execute, and the others class read only.[1] It also notes a shortcut: a digit allows execution if and only if it is odd, allows reading if it is 4 or more, and allows writing if it is 2, 3, 6 or 7.[1]
The symbolic form
The symbolic notation has the form classes, an operator and the operations, as in u=rwx,g=rx,o=rx. The classes are u for the user, g for the group, o for others, and a for all. The page warns that some people think that o means the owner, when it stands for others.[1] The calculator shows the symbolic command that sets the same bits, using the equals sign, which replaces whatever was there before. The operators + and − add or remove bits and are useful when you want to change only one thing.
Reading the ls -l string
The command ls -l reports permissions in ten letters. The first shows the type of the entry, a dash for a regular file and d for a directory. Three sets of three letters follow for the user, group and others, each with a dash where the permission is missing.[1] The page's example, -rwxr-xr--, is a regular file that the owner can read, write and execute, that the group can read and execute, and that others can only read.[1] That string is the one that the calculator shows for 754. Choose a directory to see the d at the front.
Setuid, setgid and the sticky bit
The article on file-system permissions explains the three special bits. When a file with the setuid bit is executed, the process runs with the user ID of the file's owner. With setgid, it runs with the group ID of the file's group, and on a directory, new files inherit the group of that directory. The sticky bit on a directory stops users from renaming, moving or deleting files that belong to other users, even if they have write permission to the directory, with the owner of the directory and the superuser as exceptions.[2] They are shown in the ls string by changing the execute letter: setuid changes the user's, setgid the group's and the sticky bit the others'. An x becomes s or t, and a dash becomes S or T.[2] The example -rwsr-Sr-t has all three set.[2]
In the octal form, a fourth digit at the left holds the special bits.[2] By the same rule of bits, setuid counts 4, setgid counts 2 and the sticky bit counts 1, so 4755 is 755 with setuid, and 1777 is 777 with the sticky bit. This addition is our own working, and the calculator checks it for you.
Common values, worked out
Here are a few numbers worked from the digits above. 644 is rw-r--r--: the owner may read and write, and everyone else may only read. 755 is rwxr-xr-x: the owner has all three, and others may read and execute. 600 is rw-------: only the owner may read and write. 700 is rwx------. 777 is rwxrwxrwx, which lets anyone write, so use it with great care. 000 gives nobody any access, except that the superuser is not bound by these bits. The calculator shows the same breakdown for any number you type.
Common mistakes
- Confusing o with owner. The letter o means others, and the owner is u.
- Giving write access to everyone. Modes ending in 7 or 6 let any user write.
- Forgetting that execute on a directory means entry. A directory usually needs x for people who need to open it.
- Using =, when you meant +. The equals sign replaces all the bits of that class.
What next
Use this often? Add Chmod to your Home screen.
Frequently asked questions
What is a chmod calculator?
A tool that converts file permissions into the octal number that chmod uses, and the number back into read, write and execute letters.
What does chmod 755 mean?
The owner can read, write and execute (7), and the group and others can read and execute (5). The letters are rwxr-xr-x.
How do the octal digits work?
Read is 4, write is 2 and execute is 1. Add the ones that you want to give for each of the owner, group and others.
What does the first digit of a four-digit mode do?
It holds the special bits: setuid, setgid and the sticky bit. Without it, the special bits are off.
Does this tool change my files?
No. It only works out the number and the command. You run the command yourself.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.