The getfattr tool is used to get the extended attributes of a file, but is there a tool to add an extended attribute to a file?

  • 1
    The manual page tells you that, in the see-also section. – Thomas Dickey Feb 20 '19 at 23:07
  • 'getfattr` only retrieves file ACLs, not all possible extended attributes of a file. – fpmurphy Feb 21 '19 at 2:26
  • @fpmurphy How do you know that getfattr can only retrieve the file's ACLs? based on my testings, I can use it to get other extended attributes also, for example I can get the extended user attributes using this command: getfattr -d file.txt. – John Feb 22 '19 at 14:33
  • @John Perhaps you would care to provide an example of the -d option displaying other extended attributes. AFAIK, the -d only displays the default ACL and not any other type of extended attributes. – fpmurphy Feb 25 '19 at 3:01
  • @fpmurphy I have used this command to set extended attributes: setfattr -n user.hello -v world file.txt, and this command to get extended attributes: getfattr -d -m user file.txt. I was successful in setting and getting the user and security and trusted extended attributes. But when I tried to set the system extended attributes, I got this error: setfattr: file.txt: Operation not supported, but when I tried to get the system extended attributes... – John Feb 28 '19 at 6:54

Welcome to Unix & Linux.

The setfattr command is the tool you’re looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.