Linux Exam LFCS: Default Permissions with umask | WebsiteName

Which umask value sets default file permissions to -rw-r-----? | Linux Exam LFCS

Question

Which of the following settings for umask ensures that new files have the default permissions -rw-r----- ?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

D

The umask command in Linux is used to set default permissions for new files and directories created by a user or process. The default permission is set by subtracting the umask value from 777 for directories or 666 for files.

For example, if the umask value is 022, then the default permission for a new file will be 644 (666 - 022) and for a new directory it will be 755 (777 - 022).

To ensure that new files have the default permissions -rw-r----- (i.e., read and write permission for the owner, and read permission for the group), we need to calculate the umask value that will result in a default permission of 640.

The calculation can be done as follows:

666 - umask = 640 umask = 666 - 640 umask = 026

Therefore, the answer is not listed among the given options. None of the given options will result in the desired default permission of -rw-r-----.

Option A (0017) will result in default permissions of -rw-r----x (read, write, and execute for the owner, read permission for the group, and no permission for others).

Option B (0640) will result in default permissions of -rw-r----- for files but drw-r-x--- for directories.

Option C (0038) will result in default permissions of -rw-r--r-- (read and write permission for the owner, read permission for the group and others) for files, and drwxr--r-- (read, write, and execute for the owner, read permission for the group and others) for directories.

Option D (0027) will result in default permissions of -rw-r----x for files but drwxr-x--- for directories.

Therefore, none of the given options ensures that new files have the default permissions -rw-r-----.