{
    "mode": "man",
    "parameter": "setfattr",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/setfattr/1/json",
    "generated": "2026-05-30T05:11:44Z",
    "synopsis": "setfattr [-h] -n name [-v value] pathname...\nsetfattr [-h] -x name pathname...\nsetfattr [-h] --restore=file",
    "sections": {
        "NAME": {
            "content": "setfattr - set extended attributes of filesystem objects\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "setfattr [-h] -n name [-v value] pathname...\nsetfattr [-h] -x name pathname...\nsetfattr [-h] --restore=file\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  setfattr  command associates a new value with an extended attribute name for each speci‐\nfied file.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-n --name",
                    "content": "Specifies the name of the extended attribute to set.\n",
                    "flag": "-n",
                    "long": "--name"
                },
                {
                    "name": "-v --value",
                    "content": "Specifies the new value of the extended attribute. There are three methods available  for\nencoding  the  value.  If the given string is enclosed in double quotes, the inner string\nis treated as text. In that case, backslashes and double quotes have special meanings and\nneed  to  be escaped by a preceding backslash. Any control characters can be encoded as a\nbackslash followed by three digits as its ASCII code in octal. If the given string begins\nwith  0x  or 0X, it expresses a hexadecimal number. If the given string begins with 0s or\n0S, base64 encoding is expected.  Also see the --encoding option of getfattr(1).\n",
                    "flag": "-v",
                    "long": "--value"
                },
                {
                    "name": "-x --remove",
                    "content": "Remove the named extended attribute entirely.\n",
                    "flag": "-x",
                    "long": "--remove"
                },
                {
                    "name": "-h --no-dereference",
                    "content": "Do not follow symlinks.  If pathname is a symbolic link, it is not followed, but  is  in‐\nstead itself the inode being modified.\n\n--restore=file\nRestores  extended attributes from file.  The file must be in the format generated by the\ngetfattr command with the --dump option.  If a dash (-) is given as the file  name,  set‐‐\nfattr reads from standard input.\n",
                    "flag": "-h",
                    "long": "--no-dereference"
                },
                {
                    "name": "--raw",
                    "content": "Do  not  decode  the  attribute  value.  Can be used to set values obtained with getfattr\n--only-values.\n",
                    "long": "--raw"
                },
                {
                    "name": "--version",
                    "content": "Print the version of setfattr and exit.\n",
                    "long": "--version"
                },
                {
                    "name": "--help",
                    "content": "Print help explaining the command line options.\n\n--  End of command line options.  All remaining parameters are  interpreted  as  file  names,\neven if they start with a dash character.\n",
                    "long": "--help"
                }
            ]
        },
        "EXAMPLES": {
            "content": "Add extended attribute to user namespace:\n",
            "subsections": [
                {
                    "name": "$ setfattr -n user.foo -v bar file.txt",
                    "content": "To add md5sum of the file as an extended attribute:\n"
                },
                {
                    "name": "# setfattr -n trusted.md5sum -v d41d8cd98f00b204e00998ecf8427e file.txt",
                    "content": ""
                }
            ]
        },
        "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), attr(5)\n\n\n\nDec 2001                                 Extended Attributes                             SETFATTR(1)",
            "subsections": []
        }
    },
    "summary": "setfattr - set extended attributes of filesystem objects",
    "flags": [
        {
            "flag": "-n",
            "long": "--name",
            "arg": null,
            "description": "Specifies the name of the extended attribute to set."
        },
        {
            "flag": "-v",
            "long": "--value",
            "arg": null,
            "description": "Specifies the new value of the extended attribute. There are three methods available for encoding the value. If the given string is enclosed in double quotes, the inner string is treated as text. In that case, backslashes and double quotes have special meanings and need to be escaped by a preceding backslash. Any control characters can be encoded as a backslash followed by three digits as its ASCII code in octal. If the given string begins with 0x or 0X, it expresses a hexadecimal number. If the given string begins with 0s or 0S, base64 encoding is expected. Also see the --encoding option of getfattr(1)."
        },
        {
            "flag": "-x",
            "long": "--remove",
            "arg": null,
            "description": "Remove the named extended attribute entirely."
        },
        {
            "flag": "-h",
            "long": "--no-dereference",
            "arg": null,
            "description": "Do not follow symlinks. If pathname is a symbolic link, it is not followed, but is in‐ stead itself the inode being modified. --restore=file Restores extended attributes from file. The file must be in the format generated by the getfattr command with the --dump option. If a dash (-) is given as the file name, set‐‐ fattr reads from standard input."
        },
        {
            "flag": "",
            "long": "--raw",
            "arg": null,
            "description": "Do not decode the attribute value. Can be used to set values obtained with getfattr --only-values."
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "Print the version of setfattr and exit."
        },
        {
            "flag": "",
            "long": "--help",
            "arg": null,
            "description": "Print help explaining the command line options. -- End of command line options. All remaining parameters are interpreted as file names, even if they start with a dash character."
        }
    ],
    "examples": [
        "Add extended attribute to user namespace:",
        "To add md5sum of the file as an extended attribute:"
    ],
    "see_also": [
        {
            "name": "getfattr",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/getfattr/1/json"
        },
        {
            "name": "attr",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/attr/5/json"
        }
    ]
}