In: Computer Science
The notation used in the above problem is called symbolic notation. Alternatively, we can use the 4-digit octal notation to specify, which is defined as follows: • Digits from left (most significant) to right (least significant): [special bits][owner bits][group bits][world bits] • Special bit digit = (4 if setuid) + (2 if setgid) + (1 if sticky), 0 for none of them • All other digits = (4 if readable) + (2 if writable) + (1 if executable), 0 for none of them For example, if no special bit is set on, the first digit should be a zero (i.e., “special bits”=0). For the owner bits, if the owner has read and write privileges, then the second digit should be (4 if readable) + (2 if writable) = 6 (i.e., “owner bits”=6). If group and world have no privilege, they will have a zero each, and the third and fourth digits should be 0 and 0, respectively (i.e., “group bits”=0 and “world bits”=0). The converted representation should then be “0600”. One of the useful resources for this representation is: https://en.wikipedia.org/wiki/File_system_permissions.
Convert each of the symbolic permissions to octal notation and each of the octal permissions to symbolic notation. a. -rw-r--r-- b. -rwxr-xr-x c. 0400 d. 1777 e. 4755
Based on the detailed description of the 4-digit representation of the data, we can do a mapping of the octal numbers as below(Along with their symbolic representation):
Along with the above representation, we have to consider the setuid, setgid and sticky character representation as well. This is called as extended POSIX representation of the permissions. When we have the extended representation, based on the significant octal digit's(Left Most digit in the 4-digit representation) value, the below conversion rules apply:
Based on the above description, we will be converting the symbolic notation to octal representation and vice-versa: