Skip to content
Advertisement

Why does the permission expression 653 mean rw- r-x -wx [closed]

I’m not sure whether it is chmod or unmask, but this question is from an exam, where it asks the meaning of 653

I thought 6 means Read(4) + Write(2), 5 means Read(4) plus Execute(1) and that 3 means Write(2) plus Execute(1)

So based on my thoughts, I can’t find sense in the answer, as I thought it would be something like rw r+x w+x

Why does the supposedly correct answer have the minus(-) signal instead of the plus(+)?

Advertisement

Answer

When permissions are displayed as strings, a dash in a given position means that bit isn’t set. And for each of the three octal digits that make up the basic mode, the read bit is always shown in the first position, the write bit is always shown in the second position, and the execute bit is always shown in the third position*. So 0653 appears e.g. in the output of ls -l as rw-r-x-wx.

Plusses and minuses can also be used when setting or unsetting bits with chmod, e.g. chmod u+r (set the read bit in the left-most octal digit), chmod g-w (unset the write bit in the middle octal digit). A plus or minus in this syntax has nothing to do with how it’s displayed.

* – Note that the character used to represent the execute bit (x) is sometimes overloaded to show additional information, such as the setuid and setgid bits (s or S) and the tacky bit (t).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement