What umask = 0002 means?

  1. Files have default permission as rw-rw-r--.and for directory it is as rwxrwxr-x

  2. Files have default permission as r--r--r--.and for directory it is as r-xr-xr-x

  3. Files have default permission as rw-rw-rw-.and for directory it is as rw-rw-rw-

  4. None of the above.


Correct Option: A

AI Explanation

To answer this question, let's understand what the umask value represents.

The umask value is a permission mask that is applied to newly created files and directories. It is used to modify the default permissions assigned to these files and directories.

In the case of umask = 0002, the value is represented in octal notation. Each digit in the octal value represents the permissions for different user groups: owner, group, and others.

The umask value consists of three digits, each representing the permission bits for the respective user group. The digits are subtracted from the maximum permission set (777 in octal) to determine the default permissions for files and directories.

Let's break down the umask value 0002:

  • The first digit (0) represents the owner's permissions. In this case, it is set to 0, indicating no changes to the default permissions for the owner.
  • The second digit (0) represents the group's permissions. In this case, it is set to 0, indicating no changes to the default permissions for the group.
  • The third digit (2) represents the permissions for others. In this case, it is set to 2, indicating the subtraction of write permission from the default permissions for others.

By subtracting the umask value (0002) from the maximum permission set (777), we get the default permissions for files and directories:

  • For files: 777 - 0002 = 775. This means that newly created files will have default permissions of rw-rw-r--.
  • For directories: 777 - 0002 = 775. This means that newly created directories will have default permissions of rwxrwxr-x.

Therefore, option A) Files have default permission as rw-rw-r-- and for a directory, it is as rwxrwxr-x is the correct answer.

Find more quizzes: