Doing chmod 755 on a directory gives me drwxr-xr-x. Should it not give me drwxr-xr-xr since 5 is read,execute?

And Doing chmod 751 on a directory give me drwxr-x--x. Should that not give me drwxr-xr-x?

Kindly explain.


The bits are groups of three the results are correct, I do not really get the point you misunderstood. 5 is read, execute but the order of rwx does not change. Consider them as switches, they might be on (r/w/x) or off (-). Here again an overview of the values:

7(8) = 111(2) => rwx
5(8) = 101(2) => r-x
1(8) = 001(2) => --x

Answer: It's rwx. Read. Write. Execute.

Not wxr or xrw or rxw. It's only one of the 3! different ways of arranging the letters. This may clear up some of your confusion.

Also, chmod works with an octal positional system. Octal represents base 8. Which can be represented using 1 bit with values from 0-7 inclusive - a total of 8, that's why it's called octal.

Unrelated: In binary, three 1's represent 1+2+4 = 7.


Think of it like this.

111  where 111 is a binary value

1 1 1      (binary)
4+2+1 -> 7 (decimal by position)

So 751 would be rwx r_x __x
                111 101 001 (binary)
                421 401 001 (decimal by position)
                 7   5   1  (decimal equivalent)

I also suffered this confusion. The dashes are the confusing part. One would assume that the dashes are used to separate the permission groups (7-5-1), but the dashes are not used that way in this case; there is no spacing between the permission groups and the dashes are used in the 'middle' of the permission group, so to speak, as a placeholder for nonexistence.

In short, the dashes are not used to separate the permission groups.


As Octavian says above the dashes are not used to separate user/group/all but they are used for 0 permissions. In your case if you wish to look at the user/group/all separation it would look like this:

755 would be drwxr-xr-x where you can separate like this: drwx|r-x|r-x
751 would be drwxr-x--x where you can separate like this: drwx|r-x|--x

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy