From: "Extended attributes are name:value pairs associated permanently with files and directories". There are four extended attribute classes: security, system, trusted and user.
Extended attributes are also used to set Capabilities.
User extended attributes
User extended attributes can be used to store arbitrary information about a file. To create one:
$ setfattr -n user.checksum -v "3baf9ebce4c664ca8d9e5f6314fb47fb" file.txt
Use getfattr to display extended attributes:
$ getfattr -e text -d file.txt
# file: file.txt user.checksum="3baf9ebce4c664ca8d9e5f6314fb47fb"
To remove an extended attribute:
$ setfattr -x user.checksum file.txt
To find files with certain extended attributes useAUR:
$ rh /path/to/dir '"XATTR_REGEX".reea'
Some other user extended attributes include:
user.mime_type: helps programs know mimetype and set it with less guesswork.
user.charset: used by the Apache httpd module mod_mime_xattr.
user.creator: The name of the application that created the file.
XDG also proposes a set of standardized extended attributes to be used by programs:
user.xdg.comment: supported by Dolphin and other file managers.
user.xdg.origin.url: for files downloaded from a url.
user.xdg.robots.index: "true" if a file is included in indexing, "false" otherwise
user.xdg.robots.backup: "true" if a file is included in backup, "false" otherwise
Preserving extended attributes
|Command||Preserves by default?/Required flag|
|syncthing||by enabling syncXattrs|
- mv silently discards extended attributes when the target file system does not support them.
All major Linux file systems including Ext4, Btrfs, ZFS, and XFS support extended attributes. The kernel allows to have extended attribute names of up to 255 bytes and values of up to 64 KiB, but Ext4 and Btrfs might impose smaller limits, requiring extended attributes to be within a "filesystem block".
NTFS uses Alternative Data Streams to store user. The mount option
streams_interface=xattr should be used by default. However, it might not be supported if mount option
streams_interface=windows is used. supports mapping Alternative Data Streams to extended attributes in FUSE.
NFS does not currently support extended attributes.
|Application||Supported extended attributes||Notes|
|Yes||Supported by caja-xattr-tags and caja.eiciel extensions.|
|Chromium||No||Used to support referrer and url, but was disabled due to privacy and security concerns. See also CVE-2018-20483.|
|Enabled with |
user.baloo.rating user.xdg.comment user.xdg.tags
|emacs-vm||No||Resets mbox xattrs.|
user.xdg.referrer.url user.dublincore.title user.dublincore.date user.dublincore.description user.dublincore.contributor user.dublincore.format
|Enabled with |
|Enabled with |
Other tagging systems
It might not be possible to use extended attributes due to lack of support of either the file system or software. For this reason, many media formats store metadata included in the file format that can be viewed using programs like Exiftool or more specified ones like AUR for audio.
Another filesystem-independent workaround is Gnome virtual filesystem: stores metadata this way and can be viewed with:which is used to store metadata (gvfsd-metadata). For example, Firefox
$ gio info --attributes=metadata:: downloaded.html
Other programs that use this approach include:
- Thunar: to save file color highlights.