LFCS · Question #368
Which command will set the user.author attribute on the file afile.txt?
The correct answer is B. setfattr n user.author v "A. Author" afile.txt. The setfattr command is used to set extended attributes on a file, requiring specific options to define the attribute name and its corresponding value.
Question
Options
- Asetfattr user.author:"A. Author" afile.txt
- Bsetfattr n user.author v "A. Author" afile.txt
- Csetfattr user.author="A. Author" afile.txt
- Dsetfattr a user.author="A. Author" afile.txt
How the community answered
(14 responses)- B86% (12)
- C7% (1)
- D7% (1)
Why each option
The `setfattr` command is used to set extended attributes on a file, requiring specific options to define the attribute name and its corresponding value.
The syntax `user.author:"A. Author"` is incorrect for `setfattr` as it does not properly separate the attribute name and value with the required options.
The `setfattr` command requires the attribute name to be specified using the `-n` or `--name` option, and the attribute value to be specified using the `-v` or `--value` option, making `setfattr -n user.author -v "A. Author" afile.txt` the correct syntax.
The syntax `user.author="A. Author"` is not a valid way to specify an attribute name and value for the `setfattr` command.
While `-a` is an option (for add), it's typically used with `-n` and `-v`, and the structure `a user.author="A. Author"` is an incorrect command syntax for setting an attribute and its value.
Concept tested: Setting Linux Extended Attributes (setfattr)
Source: https://linux.die.net/man/1/setfattr
Topics
Community Discussion
No community discussion yet for this question.