SETFATTR(1)
๐ setfattr โ bestie's guide to setting extended attributes
okay so this is from the File Utilities corner of the manual, and it's called setfattr (short for "set file attributes", but the extended kind, iykyk). It lives in the Extended Attributes section and honestly? It's iconic. Let's get into it.
โจ NAME โจ
setfattr โ set extended attributes of filesystem objects
Like. You're attaching little extra metadata nametags to your files. That's the whole vibe. ๐
๐ธ SYNOPSIS ๐ธ
setfattr [-h] -n name [-v value] pathname...
setfattr [-h] -x name pathname...
setfattr [-hP] --restore=file
Three modes, bestie: set a thing, remove a thing, or restore a whole pile of things from a file. Pick your fighter. ๐
๐ฆ DESCRIPTION ๐ฆ
The setfattr command associates a new value with an extended attribute name for each specified file.
That's it. That's the job. You give it a name, you give it a value, you point it at files, and it goes and does the thing. no cap. โจ
๐ OPTIONS ๐
-nname,--name=name โ Specifies the name of the extended attribute to set. You gotta have this one, it's the whole point. ๐ซถ-vvalue,--value=value โ Specifies the new value of the extended attribute. There are three methods available for encoding the value, and they are lowkey a whole personality test:- 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
0xor0X, it expresses a hexadecimal number. - If the given string begins with
0sor0S, base64 encoding is expected.
Also see the --encoding option of getfattr(1). (Sibling energy. They're a matched set. ๐)
-xname,--remove=name โ Remove the named extended attribute entirely. Bye bye, attribute. not me being emotional about it ๐ญ-h,--no-dereferenceโ Do not follow symlinks. If pathname is a symbolic link, it is not followed, but is instead modified itself. It said "I'm not chasing that link, I'm touching the link directly." main character energy fr fr.-P,--physicalโ Do not traverse symbolic links in pathnames during a restore. Can be combined with option-h. Stack 'em, bestie. ๐--restore=file โ Restores extended attributes from file. The file must be in the format generated by thegetfattrcommand with the--dumpoption. If a dash (-) is given as the file name,setfattrreads from standard input. Very "plug me into a pipe" of it. ๐--rawโ Do not decode the attribute value. Can be used to set values obtained withgetfattr --only-values. Raw as in "no filter, no makeup, just the bytes." ๐--versionโ Print the version ofsetfattrand exit. Slay, but make it brief. โญ--helpโ Print help explaining the command line options. Your bestie when you forget what-Pdoes (it's the symlink one, you're welcome). ๐--โ End of command line options. All remaining parameters are interpreted as file names, even if they start with a dash character. This is the escape hatch for files with chaotic names. ๐
๐ง EXAMPLES ๐ง
Add extended attribute to user namespace:
$ setfattr -n user.foo -v bar file.txt
To add md5sum of the file as an extended attribute:
# setfattr -n trusted.md5sum -v d41d8cd98f00b204e00998ecf8427e file.txt
Note the#on the second one, bestie โ that's root territory. Thetrusted.namespace doesn't play around. ๐
๐ AUTHOR ๐
Andreas Gruenbacher, <andreas.gruenbacher@gmail.com> and the SGI XFS development team, <linux-xfs@oss.sgi.com>.
Please send your bug reports or comments to <https://savannah.nongnu.org/bugs/?group=attr> or <acl-devel@nongnu.org>.
Legends, honestly. Respect the architects. ๐ซถ
๐ฅ SEE ALSO ๐ฅ
(the duo + the lore page. read all three, iykyk) ๐ฆ
and that's the whole page, bestie!! this one's from Dec 2001, filed under Extended Attributes, and the manual name on the tin is SETFATTR(1) โ go forth and tag your files, you absolute icon โจ๐๐
๐ฆ where this page comes from
- arch rolling: attr 2.6.0-1 ยท LGPL-2.1-or-later AND GPL-2.0-or-later
- centos-stream 10: attr 2.6.0-2.el10 ยท GPL-2.0-or-later
- centos-stream 9: attr 2.6.0-2.el9 ยท GPLv2+
- fedora 43: attr 2.6.0-1.fc43 ยท GPL-2.0-or-later
- fedora 44: attr 2.6.0-1.fc44 ยท GPL-2.0-or-later
- nixpkgs unstable: attr 2.6.0
- opensuse-leap 16.0: attr 2.6.0-160000.1.1 ยท GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: attr 2.6.0-160000.1.1 ยท GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: attr 2.6.0-160000.1.1 ยท GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: attr 2.6.0-160000.1.1 ยท GPL-2.0-or-later AND LGPL-2.1-or-later
- ubuntu noble: attr 1:2.5.2-1ubuntu0.1
- Copyright (C) 2002, 2004 Silicon Graphics, Inc. Al rights reserved
- Copyright (C) 2002, 2004 Andreas Gruenbacher <agruen@suse.de>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms