What is `xattr` on macOS

211 阅读1分钟

From the tldr, we can see:

xattr

Utility to work with extended filesystem attributes. More information: ss64.com/osx/xattr.h….

  • List key:value extended attributes for a given file: xattr -l file

  • Write an attribute for a given file: xattr -w attribute_key attribute_value file

  • Delete an attribute from a given file: xattr -d com.apple.quarantine file

  • Delete all extended attributes from a given file: xattr -c file

  • Recursively delete an attribute in a given directory: xattr -rd attribute_key directory

From the description above, xattr is a console program to display and manipulate extended attributes of one or more files. xattr is also the abbreviation of extended attributes in Unix-like systems.

With contrast to regular attributes which purpose are defined by the filesystem (such as permissions or records of creation and modification times), extended file attributes are much more flexiable to include metadata not interpreted by the filesystem such as the author of a document, the character encoding of a plain-text document, or a checksum, cryptographic hash or digital certificate, and discretionary access control information.