{
    "mode": "man",
    "parameter": "attr",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/attr/1/json",
    "generated": "2026-10-20T21:51:27Z",
    "synopsis": "attr [ -LRSq ] -s attrname [ -V attrvalue ] pathname\nattr [ -LRSq ] -g attrname pathname\nattr [ -LRSq ] -r attrname pathname\nattr [ -LRSq ] -l pathname",
    "sections": {
        "NAME": {
            "content": "attr - legacy tool to handle extended attributes on filesystem objects\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "attr [ -LRSq ] -s attrname [ -V attrvalue ] pathname\n\nattr [ -LRSq ] -g attrname pathname\n\nattr [ -LRSq ] -r attrname pathname\n\nattr [ -LRSq ] -l pathname\n\n",
            "subsections": []
        },
        "OVERVIEW": {
            "content": "Extended  attributes  implement  the ability for a user to attach name:value pairs to objects\nwithin the filesystem.\n\nThis document describes the attr command, which is mostly compatible with the IRIX command of\nthe same name.  It was originally aimed specifically at users of  the  XFS  filesystem,  even\nthough  it  can  be used now on any filesystem that supports extended attributes, but for the\ngeneric and more portable interface for filesystem independent extended  attribute  manipula‐\ntion, consult the getfattr(1) and setfattr(1) documentation.\n\nExtended attributes can be used to store meta-information about the file.  For example \"char‐\nacter-set=kanji\" could tell a document browser to use the Kanji character set when displaying\nthat document and \"thumbnail=...\" could provide a reduced resolution overview of a high reso‐\nlution graphic image.\n\nIn supported filesystems, the names can be up to 256 bytes in length, terminated by the first\n0  byte.   The  intent is that they be printable ASCII (or other character set) names for the\nattribute.  The values can be up to 64KB of arbitrary binary data.\n\nAttributes can be attached to all types  of  inodes:  regular  files,  directories,  symbolic\nlinks, device nodes, etc.\n\nExtended  attributes use several disjoint attribute namespaces associated with every filesys‐\ntem object: the trusted (or xfsroot for compatibility with IRIX) namespace,  only  accessible\nand visible to the superuser and when requested explicitly with an option, the security name‐\nspace  with  the  same  properties except used for security metadata, and the user namespace,\nwhich is protected by the normal file permissions mechanism, so the owner of the file can de‐\ncide who is able to see and/or modify the value of attributes on any particular file.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The legacy attr utility allows  the  manipulation  of  extended  attributes  associated  with\nfilesystem objects from within shell scripts.\n\nThere are four main operations that attr can perform:\n\nGET    The -g attrname option tells attr to search the named object and print (to stdout) the\nvalue  associated  with that attribute name.  With the -q flag, stdout will be exactly\nand only the value of the attribute, suitable for storage directly into a file or pro‐\ncessing via a piped command.\n\nLIST   The -l option tells attr to list the names of all the attributes that  are  associated\nwith  the  object,  and  the number of bytes in the value of each of those attributes.\nWith the -q flag, stdout will be a simple list of only the attribute  names,  one  per\nline, suitable for input into a script.\n\nREMOVE The  -r attrname option tells attr to remove an attribute with the given name from the\nobject if the attribute exists.  There is no output on successful completion.\n\nSET/CREATE\nThe -s attrname option tells attr to set the named attribute  of  the  object  to  the\nvalue  read from stdin.  If an attribute with that name already exists, its value will\nbe replaced with this one.  If an attribute with that name does not already exist, one\nwill be created with this value.  With the -V attrvalue flag, the  attribute  will  be\nset to have a value of attrvalue and stdin will not be read.  With the -q flag, stdout\nwill  not  be used.  Without the -q flag, a message showing the attribute name and the\nentire value will be printed.\n\nWhen the -L option is given and the named object is a symbolic link, operate on  the  attrib‐\nutes  of the object referenced by the symbolic link.  Without this option, operate on the at‐\ntributes of the symbolic link itself.\n\nWhen the -R option is given and the  process  has  appropriate  privileges,  operate  in  the\ntrusted (or xfsroot) attribute namespace rather that the user attribute namespace.\n\nThe -S option is similar, except it specifies use of the security attribute namespace.\n\nWhen  the  -q option is given attr will try to keep quiet.  It will output error messages (to\nstderr) but will not print status messages (to stdout).\n",
            "subsections": []
        },
        "NOTES": {
            "content": "The standard file interchange/archive programs tar(1), and cpio(1) will not  archive  or  re‐\nstore  extended  attributes.  Although GNU tar supports handling extended attributes with its\n--xattrs option.\n",
            "subsections": []
        },
        "CAVEATS": {
            "content": "The list option present in the IRIX version of this command is not supported.  getfattr  pro‐\nvides a mechanism to retrieve all of the attribute names.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Andreas  Gruenbacher,  <andreas.gruenbacher@gmail.com>  and  the  SGI  XFS  development team,\n<linux-xfs@oss.sgi.com>.\n\nPlease send your bug reports or comments to <https://savannah.nongnu.org/bugs/?group=attr> or\n<acl-devel@nongnu.org>.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "getfattr(1), setfattr(1), attrget(3), attrset(3), attrmulti(3), attrremove(3),  xattr(7),\nxfsdump(8)\n\nDec 2001                                 Extended Attributes                                 ATTR(1)",
            "subsections": []
        }
    },
    "summary": "attr - legacy tool to handle extended attributes on filesystem objects",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "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": "attrget",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/attrget/3/json"
        },
        {
            "name": "attrset",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/attrset/3/json"
        },
        {
            "name": "attrmulti",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/attrmulti/3/json"
        },
        {
            "name": "attrremove",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/attrremove/3/json"
        },
        {
            "name": "xattr",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/xattr/7/json"
        },
        {
            "name": "xfsdump",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/xfsdump/8/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Manipulate extended attributes on filesystem objects.",
        "examples": [
            {
                "description": "List the names and sizes of all extended attributes of a file",
                "command": "attr -l {{path/to/file}}"
            },
            {
                "description": "Get the value of an extended attribute",
                "command": "attr -g {{attribute_name}} {{path/to/file}}"
            },
            {
                "description": "Set an extended attribute value",
                "command": "attr -s {{attribute_name}} -V \"{{attribute_value}}\" {{path/to/file}}"
            },
            {
                "description": "Set an extended attribute using a value from `stdin`",
                "command": "echo \"{{attribute_value}}\" | attr -s {{attribute_name}} {{path/to/file}}"
            },
            {
                "description": "Remove an extended attribute",
                "command": "attr -r {{attribute_name}} {{path/to/file}}"
            }
        ]
    }
}