Page 1 of 1

Chmod Calculator – Set file permission with chmod

Chmod Calculator – Set file permission with chmod

For most of us, working in Linux or in a shell is not necessarily a daily activity, and that’s totally OK.
I’m not daily working with it either, but occasionally I use one of those funny commands to set the access rights to certain files and/or directories.

This command, chmod, is not super complicated to work with, and is commonly used when working in a shell or terminal on both the MacOS X and Linux platforms. But we need a “magci number” to set these rights. The “magic number” for chmod is also commonly used with FTP programs.

Whenever I use this command, I need to refresh my mind on how to calculate the “magic number”, and I find myself looking for a chmod calculator.
Since I’m lazy at times, I figured: why not have one on my own website?

So I started playing with JavaScript and created this chmod calculator.

The calculator

Since you’re here for the calculator, let’s get right to it:

Permissions Owner Group Other
Value for chmod 0 0 0
chmod vs ls output --- --- ---



Some background on chmod

chmod” stands for “Change Mode” which doesn’t tell us much.
It’s commonly used in Unix like systems (which includes Linux and MacOS X) to set the access rights to files and directories, and determine:

– READ, WRITE and EXECUTE rights
– for the OWNER of the file, the GROUP of users of which the owner is part, and for the OTHER users.

Obviously, setting the proper access rights is important to prevent users from getting access to files or directories they should not have access to, or have limited access to. For example: your private files, or have read only access to the company phonebook, or have the ability to run a program without the ability to delete or damage the program.

To calculate this “magic” number we simply need to add numbers.

Each “right” has a value. READ = 4, WRITE = 2 and EXECUTE = 1.
So if we want to allow reading and executing, then we get: READ (4) + EXECUTE (1) = 5.

Now this doesn’t help much, since we need to specify which user will get this right.
For this we need to understand how the magic number is setup.
The first digit is for the owner, the second number for the group and the last number for other users.

Some chmod examples

As an example, let’s assume the owner can do anything with the file: READ (4) + WRITE (2) + EXECUTE (1) = 7.
Users in the same group are allowed to read and execute the file: READ (4) + EXECUTE (1) = 5.
All the other users should be blocked: 0 (they have NO rights).

This results in: 750 which would look like this in the shell/terminal: chmod 750 <yourfile>

Another example; say we’d like everybody to have full access, so the can read, write and execute: READ (4) + WRITE (2) + EXECUTE (1) = 7.

The result: 777 which would look like this in the shell/terminal: chmod 777 <yourfile>

Another example, which is one of the mote common ones on webservers, is that the owner has full access, but everybody else can only read and execute: READ (4) + EXECUTE (1) = 5. And for the owner it’s 7 again.

The result: 755 which would look like this in the shell/terminal: chmod 755 <yourfile>

You see, it’s not complicated to calculate the magic number for chmod.

Note when you’d like to change access right for a directory, including all the files and directories it holds, you’d need to add the “-R” option, for example: chmod -R 750 <yourdirectory>

Sometimes however, when looking at a directory listing from “ls -l”, my mind draws a blank when it comes to finding the matching number. This is another way I use my new calculator. I just keep clicking until the “ls” output looks like what the calculator says and I know what chmod value I’m looking at.

chmod without the calculator

Now, experienced Linux users will probably tell me that there is an alternative way to use chmod. And there is. If you remember that.

For example, to add READ rights for the other users, to a given file: chmod o+r <yourfile>

You can find more in the man page of chmod (man chmod) or on the Wiki page.

Overige bronnen

Er zijn een aantal varianten online beschikbaar, dus als je de code zelf wilt gebruiken, kijk dan ook eens naar deze JavaScripKit codes van:


Overigens; de versie hier is niet gebaseerd op deze versies, maar ik heb wel veel geleerd van hun werk.

Donation options

Donations are very much appreciated, but not required. Donations will be used for web-hosting expenses, project hardware or a motivational boost (a drink or snack). Thank you very much for those have donated already! It's truly AwEsOmE to see that folks like our articles and small applications.


There are no comments yet.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.

Your Comment …

Friendly request to not post large files here (like source codes, log files or config files). Please use the Forum for that purpose.

Please share:
Notify me about new comments (email).
       You can also use your RSS reader to track comments.

Tweaking4All uses the free Gravatar service for Avatar display.
Tweaking4All will never share your email address with others.