exam questions

Exam XK0-004 All Questions

View all questions & answers for the XK0-004 exam

Exam XK0-004 topic 1 question 133 discussion

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

Ann, a Linux administrator, wants to edit a configuration management file. When she opens the file to edit, her text editor reports that the file has been opened in read-only mode. She then tries to edit the file as root by elevating via sudo and is still unable to save any changes. The error message in her text editor says that the read-only option is set on the file. Ann checks the permissions on the file and sees the following:
-rw-rw-r-- 1 root wheel 30 Jun 13 15:38 infrastructure.yml
Which of the following commands is the BEST option to allow her to successfully modify the file?

  • A. chmod 600 infrastructure.yml
  • B. chown root: infrastructure.yml
  • C. chattr -i infrastructure.yml
  • D. chmod o+w infrastructure.yml
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️
Reference:
https://cets.seas.upenn.edu/answers/chmod.html

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
igm
Highly Voted 4 years, 6 months ago
shouldn't be C? chattr -i
upvoted 15 times
betty_boop
4 years, 6 months ago
omg you're right! I missed it
upvoted 2 times
...
...
examtopics_htc
Most Recent 2 years, 7 months ago
Selected Answer: C
She's running it as the user, root, when she's using sudo... which has write privileges. The only other explanation is that the file is immutable, and that attribute needs to be removed.
upvoted 1 times
...
xeun88
2 years, 8 months ago
lsattr to check if the file is immutable if so we can use chattr -i to remove the immutable.
upvoted 2 times
...
emaildeprueba
3 years ago
The reason why C is correct is because the user also tried editing the file as root and was unable to, even though, root is the owner of the file. Therefore, the file must be immutable and it needs to be removed with chattr -i command
upvoted 1 times
...
JosiahJ
4 years, 1 month ago
Within the context of the question and the information given, answer D would be correct. If the "i" attribute is set to the file, then that would also make it read only. However, since the only information given in the question is the standard permissions of the file, adding the "write" permission to other users would allow the user to edit the file.
upvoted 3 times
Root_user
3 years, 11 months ago
Using "-i" removes the immutable attribute and a "+i" would add it. D would not help since the file was not able to be written to using sudo when the owner is root and the group owner is wheel.
upvoted 3 times
...
...
Sfutrell
4 years, 3 months ago
answer is c
upvoted 3 times
...
ssc1982
4 years, 5 months ago
the right answer should be C
upvoted 2 times
...
Tagg
4 years, 5 months ago
I thought the file needed to be changed? immutable – the “i” attribute makes a file immutable, which means that the file can’t be modifed, renamed, or deleted and no link to it can be created. https://geek-university.com/linux/change-file-attributes/
upvoted 3 times
Xamatia
4 years, 5 months ago
Yes, i = immutable, but if you read further on the link you provided and on the commands man page, the - operator removes the attribute while the + operator adds it.
upvoted 1 times
Xamatia
4 years, 5 months ago
So the correct answer here is C.
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 ...