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?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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.
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.
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