ATTR(1)

๐Ÿ“ฆ
version 2.6.0 ยท 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0

โœจ ATTR(1) โ€” XFS Compatibility API โœจ

okay bestie, pull up a chair, because we're talking about attr โ€” the little command that handles extended attributes on XFS filesystem objects. ๐Ÿ’… she's an icon, she's IRIX-adjacent, she's here to let you stick name:value pairs onto literally anything. no cap.


๐ŸŒธ NAME ๐ŸŒธ

attr โ€” extended attributes on XFS filesystem objects ๐Ÿฆ‹


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

attr [ -LRSq ] -s attrname [ -V attrvalue ] pathname

attr [ -LRSq ] -g attrname pathname

attr [ -LRSq ] -r attrname pathname

attr [ -LRSq ] -l pathname

four little shapes, all of them iconic, all of them doing something different. periodt. โœจ


๐Ÿ‘‘ OVERVIEW ๐Ÿ‘‘

so here's the tea: extended attributes are the whole ability for a user to attach name:value pairs to objects inside the XFS filesystem. that's it. that's the concept. ๐Ÿซถ

this page is about the attr command, which is mostly compatible with the IRIX command of the same name. so bestie, heads up โ€” this one is aimed specifically at users of the XFS filesystem. if you want filesystem-independent extended attribute manipulation, you go consult getfattr(1) and setfattr(1) instead. iykyk. ๐Ÿ’–

extended attributes are for storing meta-information about the file. the classic examples: "character-set=kanji" could tell a document browser to use the Kanji character set when displaying that document, and "thumbnail=..." could hand over a reduced-resolution overview of a high-resolution graphic image. like, she's a whole mood board attached to your file. ๐ŸŒˆ

in the XFS filesystem:

  • names can be up to 256 bytes in length, terminated by the first 0 byte. the intent is that they be printable ASCII (or some other character set) names for the attribute.
  • values can be up to 64KB of arbitrary binary data. yes, arbitrary. binary. she contains multitudes. ๐Ÿ’€

attributes can be attached to all types of XFS inodes: regular files, directories, symbolic links, device nodes, etc. everything gets a lil sticker. ๐Ÿ“

and here's the structure, pay attention: XFS uses 2 disjoint attribute name spaces associated with every filesystem object. they are the root and user address spaces.

  • the root address space is accessible only to the superuser, and then only by specifying a flag argument to the function call. other users will not see or be able to modify attributes in the root address space. ๐Ÿ”’
  • the user address space is protected by the normal file permissions mechanism, so the owner of the file can decide who is able to see and/or modify the value of attributes on any particular file. ๐Ÿ‘‘

๐Ÿ’– DESCRIPTION ๐Ÿ’–

the attr utility lets you manipulate extended attributes associated with filesystem objects from within shell scripts. yes bestie, she was made for scripting. no GUI energy whatsoever. โœจ

there are four main operations that attr can perform:

๐Ÿ”ฅ GET

the -g attrname option tells attr to search the named object and print (to stdout) the value associated with that attribute name. with the -q flag, stdout will be exactly and only the value of the attribute โ€” suitable for storage directly into a file or processing via a piped command. chef's kiss, she's clean. ๐ŸŽ€

๐Ÿ”ฅ LIST

the -l option tells attr to list the names of all the attributes associated with the object, and the number of bytes in the value of each of those attributes. with the -q flag, stdout will be a simple list of only the attribute names, one per line, suitable for input into a script. โœจ

๐Ÿ”ฅ REMOVE

the -r attrname option tells attr to remove an attribute with the given name from the object if the attribute exists. there is no output on successful completion. she simply does the deed and leaves. silent. iconic. ๐Ÿ’…

๐Ÿ”ฅ SET/CREATE

the -s attrname option tells attr to set the named attribute of the object to the value read from stdin.

  • if an attribute with that name already exists, its value will be replaced with this one.
  • if an attribute with that name does not already exist, one will be created with this value.

with the -V attrvalue flag, the attribute will be set to have a value of attrvalue and stdin will not be read. ๐Ÿฆ‹

with the -q flag, stdout will not be used. without the -q flag, a message showing the attribute name and the entire value will be printed. ๐Ÿ“


๐ŸŒธ the flags that change the whole vibe ๐ŸŒธ

when the -L option is given and the named object is a symbolic link, operate on the attributes of the object referenced by the symbolic link. without this option, operate on the attributes of the symbolic link itself. choose your fighter. ๐Ÿ’ซ

when the -R option is given and the process has appropriate privileges, operate in the root attribute namespace rather than the USER attribute namespace. ๐Ÿ”ฅ

the -S option is similar, except it specifies use of the security attribute namespace. ๐Ÿ›ก๏ธ

when the -q option is given attr will try to keep quiet. she will output error messages (to stderr) but will not print status messages (to stdout). she's not being rude, she's just being efficient, bestie. ๐Ÿ˜ญ


๐Ÿ“ NOTES ๐Ÿ“

the standard file interchange/archive programs tar(1) and cpio(1) will not archive or restore extended attributes. meanwhile xfsdump(8) will. so if you're archiving your attributes, pick the right tool or your lil name:value babies are going nowhere. ๐Ÿ’€


โš ๏ธ CAVEATS โš ๏ธ

bestie listen. the list option present in the IRIX version of this command is not supported. ๐Ÿ˜ญ

getfattr provides a mechanism to retrieve all of the attribute names. so if that's what you needed, that's where you go. no cap.


๐Ÿซถ 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>. they want to hear from you, fr fr. ๐Ÿ’Œ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ


and that's the whole page, bestie!! ๐ŸŽ€ this was written all the way back in Dec 2001, from the Extended Attributes manual, page ATTR(1). she's vintage, she's XFS-specific, and she still slays. go forth and attach some name:value pairs. mwah. ๐Ÿ’–โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from