TOC   Previous   Next

Extended Attributes

Manipulating EAs from the shell

The setfattr and getfattr commands can be used to manipulate EAs on a file.

Create two EAs for a file, and display one of them:

bash$ setfattr -n user.x -v "The past is not dead." tfile
bash$ setfattr -n user.y -v "In fact, it's not even past." tfile
bash$ getfattr -n user.x tfile      
# file: tfile                       
user.x="The past is not dead."     

Display all EAs on a file:

bash$ getfattr -d tfile             
# file: tfile
user.x="The past is not dead."
user.y="In fact, it's not even past."

Change the value of an EA to an empty string:

bash$ setfattr -n user.x tfile      
bash$ getfattr -d tfile
# file: tfile
user.x
user.y="In fact, it's not even past."

Remove an EA:

bash$ setfattr -x user.y tfile
bash$ getfattr -d tfile             
# file: tfile
user.x

By default, getfattr only lists the values of user EAs. We can list all EAs on a file using:

bash$ getfattr -m - file.


(C) 2006, Michael Kerrisk