exam questions

Exam XK0-005 All Questions

View all questions & answers for the XK0-005 exam

Exam XK0-005 topic 1 question 30 discussion

Actual exam question from CompTIA's XK0-005
Question #: 30
Topic #: 1
[All XK0-005 Questions]

A systems administrator requires that all files that are created by the user named web have read-only permissions by the owner. Which of the following commands will satisfy this requirement?

  • A. chown web:web /home/web
  • B. chmod -R 400 /home/web
  • C. echo "umask 377" >> /home/web/.bashrc
  • D. setfacl read /home/web
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
linux_admin
Highly Voted 2 years, 2 months ago
Selected Answer: C
The correct answer is C. The "echo "umask 377" >> /home/web/.bashrc" command will satisfy the requirement by adding the umask setting to the user's .bashrc file. The umask setting determines the default file permissions for newly created files and directories. The value of 377 sets the default permissions to read-only for the owner of the file. The umask is specified in octal notation, and each digit represents the permissions for a different category of users. In this case, the first digit represents the permissions for the owner of the file, the second digit represents the permissions for the group owner of the file, and the third digit represents the permissions for others. A value of 3 means that the owner has read and write permissions, and a value of 7 means that the owner has read, write, and execute permissions. By setting the umask to 377, the owner of newly created files will have read-only permissions, the group owner will have no permissions, and others will have no permissions.
upvoted 5 times
clair12
6 months, 3 weeks ago
why do the group and others not have permissions? doesnt 7 mean rwx?
upvoted 2 times
...
...
bc1235813
Most Recent 1 year, 1 month ago
Selected Answer: C
The question states files that "are" created not "were" created. "B" takes care of files that "were" created/exist, "C" takes care of files that "are" (implying in the future) created. Semantics of the english language.
upvoted 2 times
...
e418137
1 year, 2 months ago
Selected Answer: C
Demonstrable: `UMASK=$(umask); umask 377; touch file; mkdir dir; umask $UMASK; unset UMASK; ls -l`
upvoted 1 times
...
DRVision
1 year, 5 months ago
Selected Answer: C
B is incorrect as the -R makes it recursive and it will change all the contents of already created files but will not affect any new files C is correct the correct option
upvoted 1 times
DRVision
1 year, 5 months ago
Here’s how you can convert the octal number 377 to binary: 3 in octal is 011 in binary. 7 in octal is 111 in binary. 7 in octal is 111 in binary. 011 means read (r) permission is denied and write (w) and execute (x) permissions are granted. 111 means read (r), write (w), and execute (x) permissions are granted. 111 means read (r), write (w), and execute (x) permissions are granted.
upvoted 3 times
DRVision
1 year, 5 months ago
Therefore, a umask of 377 typically results in new files having read-only permissions for the owner, and no permissions for the group and others. and b appending this umask to the user web bashrc file, anything they create will have a default read permissions. Echo works like a print statement, not displays what the user wants...lol
upvoted 1 times
...
...
...
cruxty
1 year, 7 months ago
Echo doesn't change anything it just displays what the user wants in the echo requests output Echo Answer is B answer is b
upvoted 3 times
...
Rob74613
2 years ago
Selected Answer: B
The permission value of 400 translates to read-only permission for the owner and no permission for the group and others. By using this command, all files created by the user web within the /home/web directory will have read-only permission for the owner, which meets the requirement. However its highly voted that "C" is the answer but I believe its wrong for this reason. The "umask" command is used to set the default permissions for new files and directories created by the user. In this case, the value "377" is being set as the umask, which means that any new files or directories created by the user will have permissions set to 600 (read and write access for the owner, and no access for group members or others). Which question specifically mentions "Read-Only"
upvoted 1 times
Rob74613
1 year, 11 months ago
***Disregard, I'm an idiot, dont listen to me...I change my answer to C***
upvoted 1 times
luken7777
1 year, 10 months ago
why?!!! you were absolutely right with your first answer. Anyone who think that the right answer is C should think really hard about their life. "umask 377" - in binary 3 = 011 7 = 111 7 = 111 Then, we invert each bit to get the bits that should be turned off: 011 -> 100 111 -> 000 111 -> 000 And there you have 100 which in decimal is 600 (4 - read, 2 write). Question says that the owner of the file should have read permission only - 400, so that automatically excludes C as the answer.
upvoted 5 times
luken7777
1 year, 10 months ago
Update: And there you have 100 000 000 which in decimal is 600 (4 - read, 2 write).
upvoted 2 times
...
Rob74613
1 year, 10 months ago
Incorrect, you're off a tad here, since we're working with a directory they umask is set to 777 777 -> 111 111 111 377 -> 011 111 111 100 000 000 When you convert 100 from binary to decimal you get 4 (not 6). Your calculating the binary left to right instead of right to left. 00000100 =2^2 Also: https://www.linuxtrainingacademy.com/all-umasks/
upvoted 2 times
...
...
...
...
angellorv
2 years, 1 month ago
Answer B: chmod changes the permissions of each given file according to mode; -R (recursive flag - successive executions); 400 = owner "read", group "---", others "---"; to the home directory of user "web" Every file created by "web" will have 400 permissions after this point
upvoted 3 times
...
nixonbii
2 years, 2 months ago
I found the umask field on CentOS8 in the /etc/profile file, nothing in .bashrc. On Ubuntu, no umask field in .bashrc, /etc/profile or /etc/bash.bashrc. I guess it has to be inserted if you want to apply it.
upvoted 1 times
...
nixonbii
2 years, 2 months ago
Looked at the .bashrc file and reviewed the study guide. The file is used to configure bash shell for a given user. Found no stubs or commented out sections for the umask command. Can someone explain?
upvoted 1 times
...
Pinnubhai
2 years, 4 months ago
Selected Answer: C
answer is C
upvoted 2 times
...
poni0331
2 years, 4 months ago
Selected Answer: C
C is correct here
upvoted 2 times
...
Nvoid
2 years, 5 months ago
Selected Answer: C
Charlie mods!!
upvoted 2 times
...
Veteran903
2 years, 5 months ago
Tested on centOS 9, answer is C
upvoted 3 times
...
bjornborg
2 years, 6 months ago
Selected Answer: C
yep, C
upvoted 2 times
...
MissAllen
2 years, 6 months ago
I agree with C, however I would have preferred the umask value be set at 0277. The default mode for directories is 777, so applying umask 0377 leaves you with octal 400 for directory creation. The question is asking about creating new files, so applying 0377 to the default mode for files of 666, you get 300 for the permissions, which is -wx for the web user. Not quite read.
upvoted 4 times
...
ryanzou
2 years, 6 months ago
Selected Answer: C
C seems correct.
upvoted 1 times
...
TheRealManish
2 years, 6 months ago
Selected Answer: C
It seems like the answer is C? the key here is that it is "all files that are created", so it is not a one time permission change.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago