Chmod 755 and 751

4

2

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.

user573526

Posted 2011-02-14T20:35:29.383

Reputation:

Answers

10

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

jdehaan

Posted 2011-02-14T20:35:29.383

Reputation: 903

0

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.

lanparty

Posted 2011-02-14T20:35:29.383

Reputation: 11

0

Think of it like this.

rwx
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)

John Czukkermann

Posted 2011-02-14T20:35:29.383

Reputation: 176

0

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.

Octavian

Posted 2011-02-14T20:35:29.383

Reputation: 101