xattr
操作 文件/目录 扩展属性。
格式
xattr [opt] [file]
说明
[root@sylixos:/root]# help xattr
set / get / delete / list file extended attributes.
eg. -s file key value Set
-g file key Get
-gb file key Get as hex show
-d file key Delete
-l file List all key
xattr opt file ...
[root@sylixos:/root]#
此命令用来操作 文件/目录 的扩展属性。有 5 种用法:
- 选项 -s:创建扩展属性,需要提供一个键值对
- 选项 -g:查看指定扩展属性的值
- 选项 -gb:以HEX码格式显示指定扩展属性的值
- 选项 -d:删除指定扩展属性
- 选项 -l:列出所有扩展属性
样例
[root@sylixos:/root]# xattr -s test_file key1 value1
[root@sylixos:/root]# xattr -l test_file
'key1'
[root@sylixos:/root]# xattr -g test_file key1
'value1'
[root@sylixos:/root]# xattr -gb test_file key1
HEX: 76 61 6c 75 65 31
[root@sylixos:/root]# xattr -d test_file key1
[root@sylixos:/root]# xattr -l test_file
No extended attributes in this file.
[root@sylixos:/root]#