Linux Commands

You can set, retrieve, restore, and remove extended attributes on files, directories, and FUSE mounted file path using Linux commands. For more information, refer to the respective Linux man page.

Note: To use extended attributes on files on a MapR cluster with a FUSE client mounted path, see Configuring the MapR FUSE-Based POSIX Client to enable extended attributes through FUSE client.

Set Extended Attributes

To set an extended attribute name and value on a file/directory and/or a FUSE mounted file path, run one of the following command:

setfattr [-h] -n name [-v value] pathname...

For example:

# setfattr -n user.test -v test test2

For more information, refer to the Linux man page.

Retrieve Extended Attributes

To retrieve extended attributes, run one of the following commands:

getfattr [-hRLP] -n name [-e en] pathname...
getfattr [-hRLP] -d [-e en] [-m pattern] pathname...

For example, to retrieve:

  • An attribute:
    # getfattr -d test2
    # file: test2
    user.test="test"
  • An attribute and send the output to a file:
    # getfattr -d test2 > testout
    # cat testout
    # file: test2
    user.test="test"

For more information, refer to the Linux man page.

Remove Extended Attributes

To remove an extended attribute by name, run the following command:

setfattr [-h] -x name pathname...

For example:

# setfattr -x user.test test2

For more information, refer to the Linux man page.

Restore Extended Attributes

To restore extended attributes from a file, which must be in the format generated by the getfattr command with the --dump option, run the following command:

setfattr [-h] --restore=file...

For example:

# setfattr --restore=testout
# getfattr -d test2
# file: test2
user.test="test"

For more information, refer to the Linux man page.