Q97: Unix/Linux file permissions

Question #97: In linux, file permissions to any file can be of the following form:

(r w x) – (r w x) – (r w x)
(user permission) – (group permission) – (others permission)

Where, r means read access, w means write access and x means executable access.

Each bit can be 0 or 1. For example, if ‘w’ bit of user permission is 0, user can’t write on to that file. What will be the file permission value if we want the user to have all read, write and executable permissions while the group and other users should only be able to read the file?

Options:

  1. 0x777
  2. 0x744
  3. 0x722
  4. 0x700

Solution: The correct answer is second one. For user permission, all 3 bits need to be 1 thereby making it 0x7. For group and others, we only need read access; hence bit pattern should be 100, which is 0x4. Hence it becomes 0x744.