# Attr - legacy tool to handle extended attributes on filesyste... - man - [phpMan]

> **TLDR:** Manipulate extended attributes on filesystem objects.
>
- List the names and sizes of all extended attributes of a file:
  `attr -l {{path/to/file}}`
- Get the value of an extended attribute:
  `attr -g {{attribute_name}} {{path/to/file}}`
- Set an extended attribute value:
  `attr -s {{attribute_name}} -V "{{attribute_value}}" {{path/to/file}}`
- Set an extended attribute using a value from `stdin`:
  `echo "{{attribute_value}}" | attr -s {{attribute_name}} {{path/to/file}}`
- Remove an extended attribute:
  `attr -r {{attribute_name}} {{path/to/file}}`

*Source: tldr-pages*

---

[_ATTR_(1)](https://www.chedong.com/phpMan.php/man/ATTR/1/markdown)                                 XFS Compatibility API                                [_ATTR_(1)](https://www.chedong.com/phpMan.php/man/ATTR/1/markdown)

## NAME
       attr - legacy tool to handle extended attributes on filesystem objects

## SYNOPSIS
       **attr **[ **-LRSq **] **-s _**attrname_ [ **-V _**attrvalue_ ] _pathname_

       **attr **[ **-LRSq **] **-g _**attrname_ _pathname_

       **attr **[ **-LRSq **] **-r _**attrname_ _pathname_

       **attr **[ **-LRSq **] **-l _**pathname_


## OVERVIEW
       Extended  attributes  implement  the ability for a user to attach name:value pairs to objects
       within the filesystem.

       This document describes the **attr **command, which is mostly compatible with the IRIX command of
       the same name.  It was originally aimed specifically at users of  the  XFS  filesystem,  even
       though  it  can  be used now on any filesystem that supports extended attributes, but for the
       generic and more portable interface for filesystem independent extended  attribute  manipula‐
       tion, consult the [**getfattr**(1)](https://www.chedong.com/phpMan.php/man/getfattr/1/markdown) and [**setfattr**(1)](https://www.chedong.com/phpMan.php/man/setfattr/1/markdown) documentation.

       Extended attributes can be used to store meta-information about the file.  For example "char‐
       acter-set=kanji" could tell a document browser to use the Kanji character set when displaying
       that document and "thumbnail=..." could provide a reduced resolution overview of a high reso‐
       lution graphic image.

       In supported filesystems, the _names_ can be up to 256 bytes in length, terminated by the first
       0  byte.   The  intent is that they be printable ASCII (or other character set) names for the
       attribute.  The _values_ can be up to 64KB of arbitrary binary data.

       Attributes can be attached to all types  of  inodes:  regular  files,  directories,  symbolic
       links, device nodes, etc.

       Extended  attributes use several disjoint attribute namespaces associated with every filesys‐
       tem object: the **trusted **(or **xfsroot **for compatibility with IRIX) namespace,  only  accessible
       and visible to the superuser and when requested explicitly with an option, the **security **name‐
       space  with  the  same  properties except used for security metadata, and the **user **namespace,
       which is protected by the normal file permissions mechanism, so the owner of the file can de‐
       cide who is able to see and/or modify the value of attributes on any particular file.

## DESCRIPTION
       The legacy **attr **utility allows  the  manipulation  of  extended  attributes  associated  with
       filesystem objects from within shell scripts.

       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 pro‐
              cessing via a piped command.

       **LIST   **The **-l **option tells **attr **to list the names of all the attributes that  are  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.

       **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.

       When the **-L **option is given and the named object is a symbolic link, operate on  the  attrib‐
       utes  of the object referenced by the symbolic link.  Without this option, operate on the at‐
       tributes of the symbolic link itself.

       When the **-R **option is given and the  process  has  appropriate  privileges,  operate  in  the
       **trusted **(or **xfsroot**) attribute namespace rather that 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.  It will output error messages (to
       _**stderr_**) but will not print status messages (to _**stdout_**).

## NOTES
       The standard file interchange/archive programs [**tar**(1)](https://www.chedong.com/phpMan.php/man/tar/1/markdown), and [**cpio**(1)](https://www.chedong.com/phpMan.php/man/cpio/1/markdown) will not  archive  or  re‐
       store  extended  attributes.  Although GNU tar supports handling extended attributes with its
       **--xattrs **option.

## CAVEATS
       The list option present in the IRIX version of this command is not supported.  **getfattr  **pro‐
       vides a mechanism to retrieve all of the attribute names.

## 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_>>.

## SEE ALSO
       [**getfattr**(1)](https://www.chedong.com/phpMan.php/man/getfattr/1/markdown), [**setfattr**(1)](https://www.chedong.com/phpMan.php/man/setfattr/1/markdown), [**attr_get**(3)](https://www.chedong.com/phpMan.php/man/attrget/3/markdown), [**attr_set**(3)](https://www.chedong.com/phpMan.php/man/attrset/3/markdown), [**attr_multi**(3)](https://www.chedong.com/phpMan.php/man/attrmulti/3/markdown), [**attr_remove**(3)](https://www.chedong.com/phpMan.php/man/attrremove/3/markdown),  [**xattr**(7)](https://www.chedong.com/phpMan.php/man/xattr/7/markdown),
       [**xfsdump**(8)](https://www.chedong.com/phpMan.php/man/xfsdump/8/markdown)

Dec 2001                                 Extended Attributes                                 [_ATTR_(1)](https://www.chedong.com/phpMan.php/man/ATTR/1/markdown)
