303-300 · Question #118
Which command is used to set an extended attribute on a file in Linux?
The correct answer is B. setfattr. setfattr (option B) is the command used to set extended attributes on a file in Linux - for example, setfattr -n user.comment -v "hello" file.txt. Option A (getfattr) is its counterpart for reading extended attributes, not writing them. Options C and D (getfacl/setfacl) deal…
Question
Which command is used to set an extended attribute on a file in Linux?
Options
- Agetfattr
- Bsetfattr
- Cgetfacl
- Dsetfacl
How the community answered
(17 responses)- B94% (16)
- D6% (1)
Explanation
setfattr (option B) is the command used to set extended attributes on a file in Linux - for example, setfattr -n user.comment -v "hello" file.txt. Option A (getfattr) is its counterpart for reading extended attributes, not writing them. Options C and D (getfacl/setfacl) deal with Access Control Lists (ACLs), which are a different mechanism for controlling file permissions, not general extended attributes.
Memory tip: The prefix tells you the action - set = write, get = read - and the suffix tells you the target - fattr = file attributes (xattrs), facl = file ACLs. Match the verb and the noun to pick the right tool.
Topics
Community Discussion
No community discussion yet for this question.