attr
TLDR
Set an extended attribute on a file
SYNOPSIS
attr [-LRSq] -s attrname [-V attrvalue] pathname
attr [-LRSq] -g attrname pathname
attr [-LRSq] -r attrname pathname
attr [-LRSq] -l pathname
DESCRIPTION
attr manipulates extended attributes on filesystem objects. Extended attributes are name-value pairs permanently associated with files and directories, providing metadata storage beyond traditional Unix permissions.
Attributes exist in namespaces: user for arbitrary user data, system for OS features like ACLs, security for SELinux labels, and trusted for privileged applications. The attr command primarily works with the user namespace.
Extended attributes persist across copy and backup operations when tools support them. Common uses include storing file metadata, checksums, capabilities, and application-specific data without modifying file content.
The related commands getfattr and setfattr provide more detailed control and are preferred for scripting.
PARAMETERS
-s attrname
Set the named attribute.-g attrname
Get and display the value of the named attribute.-r attrname
Remove the named attribute.-l
List all extended attributes on the file.-V attrvalue
Specify the value when setting an attribute.-L
Follow symbolic links.-R
Operate on attributes in the root namespace (requires privileges).-S
Operate on attributes in the security namespace.-q
Quiet mode; suppress most error messages.
CAVEATS
Not all filesystems support extended attributes; ext4, XFS, and Btrfs do when mounted with user_xattr. Attribute size limits vary by filesystem (typically 64KB). Many backup and file transfer tools do not preserve extended attributes by default. The user namespace is limited to processes with read/write access to the file.
HISTORY
Extended attributes were added to Linux in kernel 2.6 (2003), inspired by similar features in IRIX and other Unix systems. The implementation followed the POSIX 1003.1e draft standard for extended security attributes. The attr package providing these utilities has been the standard interface for managing extended attributes since their introduction.


