{
    "content": [
        {
            "type": "text",
            "text": "# xattr(7) (man)\n\n## TLDR\n\n> Utility to work with extended filesystem attributes.\n\n- List key:value extended attributes for a given file:\n  `xattr -l {{file}}`\n- Write an attribute for a given file:\n  `xattr -w {{attribute_key}} {{attribute_value}} {{file}}`\n- Delete an attribute from a given file:\n  `xattr -d {{com.apple.quarantine}} {{file}}`\n- Delete all extended attributes from a given file:\n  `xattr -c {{file}}`\n- Recursively delete an attribute in a given directory:\n  `xattr -rd {{attribute_key}} {{directory}}`\n\n*Source: tldr-pages*\n\n---\n\n**Summary:** xattr - Extended attributes\n\n## See Also\n\n- attr(1)\n- getfattr(1)\n- setfattr(1)\n- getxattr(2)\n- ioctliflags(2)\n- listxattr(2)\n- attr(2)\n- setxattr(2)\n- acl(5)\n- capabilities(7)\n- selinux(8)\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (19 lines) — 6 subsections\n  - Extended attribute namespaces (11 lines)\n  - Extended security attributes (7 lines)\n  - System extended attributes (4 lines)\n  - Trusted extended attributes (5 lines)\n  - User extended attributes (18 lines)\n  - Filesystem differences (24 lines)\n- **CONFORMING TO** (3 lines)\n- **NOTES** (6 lines)\n- **SEE ALSO** (3 lines)\n- **COLOPHON** (7 lines)\n\n## Full Content\n\n### NAME\n\nxattr - Extended attributes\n\n### DESCRIPTION\n\nExtended  attributes  are name:value pairs associated permanently with files and directories,\nsimilar to the environment strings associated with a process.  An attribute may be defined or\nundefined.  If it is defined, its value may be empty or non-empty.\n\nExtended attributes are extensions to the normal attributes which are associated with all in‐\nodes in the system (i.e., the stat(2) data).  They are often used to provide additional func‐\ntionality  to  a  filesystem—for example, additional security features such as Access Control\nLists (ACLs) may be implemented using extended attributes.\n\nUsers with search access to a file or directory may use listxattr(2) to retrieve  a  list  of\nattribute names defined for that file or directory.\n\nExtended  attributes  are  accessed  as  atomic objects.  Reading (getxattr(2)) retrieves the\nwhole value of an attribute and stores it in a buffer.  Writing  (setxattr(2))  replaces  any\nprevious value with the new value.\n\nSpace  consumed  for  extended  attributes may be counted towards the disk quotas of the file\nowner and file group.\n\n#### Extended attribute namespaces\n\nAttribute names are null-terminated strings.  The attribute name is always specified  in  the\nfully  qualified  namespace.attribute form, for example, user.mimetype, trusted.md5sum, sys‐\ntem.posixaclaccess, or security.selinux.\n\nThe namespace mechanism is used to define different classes of  extended  attributes.   These\ndifferent  classes  exist  for several reasons; for example, the permissions and capabilities\nrequired for manipulating extended attributes of one namespace may differ to another.\n\nCurrently, the security, system, trusted, and user extended attribute classes are defined  as\ndescribed below.  Additional classes may be added in the future.\n\n#### Extended security attributes\n\nThe  security  attribute  namespace  is used by kernel security modules, such as Security En‐\nhanced Linux, and also to implement file capabilities (see capabilities(7)).  Read and  write\naccess  permissions to security attributes depend on the policy implemented for each security\nattribute by the security module.  When no security module is loaded, all processes have read\naccess  to  extended  security attributes, and write access is limited to processes that have\nthe CAPSYSADMIN capability.\n\n#### System extended attributes\n\nSystem extended attributes are used by the kernel to store system objects such as Access Con‐\ntrol  Lists.  Read and write access permissions to system attributes depend on the policy im‐\nplemented for each system attribute implemented by filesystems in the kernel.\n\n#### Trusted extended attributes\n\nTrusted extended attributes are visible and  accessible  only  to  processes  that  have  the\nCAPSYSADMIN  capability.  Attributes in this class are used to implement mechanisms in user\nspace (i.e., outside the kernel) which keep information in extended attributes to which ordi‐\nnary processes should not have access.\n\n#### User extended attributes\n\nUser extended attributes may be assigned to files and directories for storing arbitrary addi‐\ntional information such as the mime type, character set or encoding of a  file.   The  access\npermissions  for  user attributes are defined by the file permission bits: read permission is\nrequired to retrieve the attribute value, and writer permission is required to change it.\n\nThe file permission bits of regular files and directories are  interpreted  differently  from\nthe file permission bits of special files and symbolic links.  For regular files and directo‐\nries the file permission bits define access to the file's contents, while for device  special\nfiles  they  define access to the device described by the special file.  The file permissions\nof symbolic links are not used in access checks.  These differences would allow users to con‐\nsume  filesystem  resources  in  a  way  not  controllable  by disk quotas for group or world\nwritable special files and directories.\n\nFor this reason, user extended attributes are allowed only for regular files and directories,\nand access to user extended attributes is restricted to the owner and to users with appropri‐\nate capabilities for directories with the sticky bit set (see the chmod(1) manual page for an\nexplanation of the sticky bit).\n\n#### Filesystem differences\n\nThe kernel and the filesystem may place limits on the maximum number and size of extended at‐\ntributes that can be associated with a file.  The VFS imposes limitations that  an  attribute\nnames is limited to 255 bytes and an attribute value is limited to 64 kB.  The list of attri‐\nbute names that can be returned is also limited to 64 kB (see BUGS in listxattr(2)).\n\nSome filesystems, such as Reiserfs (and, historically, ext2 and ext3), require the filesystem\nto  be  mounted  with the userxattr mount option in order for user extended attributes to be\nused.\n\nIn the current ext2, ext3, and ext4 filesystem implementations, the total bytes used  by  the\nnames and values of all of a file's extended attributes must fit in a single filesystem block\n(1024, 2048 or 4096 bytes, depending on the block size specified when the filesystem was cre‐\nated).\n\nIn  the  Btrfs,  XFS, and Reiserfs filesystem implementations, there is no practical limit on\nthe number of extended attributes associated with a file, and the algorithms  used  to  store\nextended attribute information on disk are scalable.\n\nIn  the  JFS,  XFS, and Reiserfs filesystem implementations, the limit on bytes used in an EA\nvalue is the ceiling imposed by the VFS.\n\nIn the Btrfs filesystem implementation, the total bytes used for the name, value, and  imple‐\nmentation overhead bytes is limited to the filesystem nodesize value (16 kB by default).\n\n### CONFORMING TO\n\nExtended  attributes are not specified in POSIX.1, but some other systems (e.g., the BSDs and\nSolaris) provide a similar feature.\n\n### NOTES\n\nSince the filesystems on which extended attributes are stored might also be used on architec‐\ntures with a different byte order and machine word size, care should be taken to store attri‐\nbute values in an architecture-independent format.\n\nThis page was formerly named attr(5).\n\n### SEE ALSO\n\nattr(1),  getfattr(1),  setfattr(1),  getxattr(2),  ioctliflags(2),  listxattr(2),  removex‐‐\nattr(2), setxattr(2), acl(5), capabilities(7), selinux(8)\n\n### COLOPHON\n\nThis  page  is  part  of  release  5.10 of the Linux man-pages project.  A description of the\nproject, information about reporting bugs, and the latest version of this page, can be  found\nat https://www.kernel.org/doc/man-pages/.\n\n\n\nLinux                                        2020-06-09                                     XATTR(7)\n\n"
        }
    ],
    "structuredContent": {
        "command": "xattr",
        "section": "7",
        "mode": "man",
        "summary": "xattr - Extended attributes",
        "synopsis": null,
        "tldr_summary": "Utility to work with extended filesystem attributes.",
        "tldr_examples": [
            {
                "description": "List key:value extended attributes for a given file",
                "command": "xattr -l {{file}}"
            },
            {
                "description": "Write an attribute for a given file",
                "command": "xattr -w {{attribute_key}} {{attribute_value}} {{file}}"
            },
            {
                "description": "Delete an attribute from a given file",
                "command": "xattr -d {{com.apple.quarantine}} {{file}}"
            },
            {
                "description": "Delete all extended attributes from a given file",
                "command": "xattr -c {{file}}"
            },
            {
                "description": "Recursively delete an attribute in a given directory",
                "command": "xattr -rd {{attribute_key}} {{directory}}"
            }
        ],
        "tldr_source": "official",
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "attr",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/attr/1/json"
            },
            {
                "name": "getfattr",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/getfattr/1/json"
            },
            {
                "name": "setfattr",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/setfattr/1/json"
            },
            {
                "name": "getxattr",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/getxattr/2/json"
            },
            {
                "name": "ioctliflags",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/ioctliflags/2/json"
            },
            {
                "name": "listxattr",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/listxattr/2/json"
            },
            {
                "name": "attr",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/attr/2/json"
            },
            {
                "name": "setxattr",
                "section": "2",
                "url": "https://www.chedong.com/phpMan.php/man/setxattr/2/json"
            },
            {
                "name": "acl",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/acl/5/json"
            },
            {
                "name": "capabilities",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/capabilities/7/json"
            },
            {
                "name": "selinux",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/selinux/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 19,
                "subsections": [
                    {
                        "name": "Extended attribute namespaces",
                        "lines": 11
                    },
                    {
                        "name": "Extended security attributes",
                        "lines": 7
                    },
                    {
                        "name": "System extended attributes",
                        "lines": 4
                    },
                    {
                        "name": "Trusted extended attributes",
                        "lines": 5
                    },
                    {
                        "name": "User extended attributes",
                        "lines": 18
                    },
                    {
                        "name": "Filesystem differences",
                        "lines": 24
                    }
                ]
            },
            {
                "name": "CONFORMING TO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "COLOPHON",
                "lines": 7,
                "subsections": []
            }
        ]
    }
}