getfattr 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

getfattr 命令安装:


-bash: getfattr command not found

 Debian
apt-get install attr
 Ubuntu
apt-get install attr
 Alpine
apk add attr
 Arch Linux
pacman -S attr
 Kali Linux
apt-get install attr
 CentOS
yum install attr
 Fedora
dnf install attr
 Raspbian
apt-get install attr
 Docker
docker run cmd.cat/getfattr getfattr

getfattr 命令补充说明:


attr 是一组用于操作文件系统对象(尤其是 getfattr 和 setfattr)上的扩展属性的工具。还提供了一个attr命令,该命令与同名的 SGI IRIX 工具在很大程度上兼容。对于每个文件,getfattr 都会显示文件名以及与该文件关联的一组扩展属性名(以及可选的值)。

getfattr 命令语法:


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

getfattr 命令选项:


-n name, --name=name
Dump the value of the named extended attribute extended attribute.

-d, --dump
Dump the values of all extended attributes associated with pathname.

-e en, --encoding=en
Encode values after retrieving them. Valid values of en are "text", "hex", and "base64". Values encoded as text strings are enclosed in double quotes ("), while strings encoded as hexidecimal and base64 are prefixed with 0x and 0s, respectively.

-h, --no-dereference
Do not dereference symlinks. Instead of the file a symlink refers to, the symlink itself is examined. Unless doing a logical (-L) traversal, do not traverse symlinks to directories.

-m pattern, --match=pattern
Only include attributes with names matching the regular expression pattern. The default value for pattern is "^user\\.", which includes all the attributes in the user namespace. Specify "-" for including all attributes. Refer to attr(5) for a more detailed discussion of namespaces.

--absolute-names
Do not strip leading slash characters ('/'). The default behaviour is to strip leading slash characters.

--only-values
Dump out the extended attribute value(s) only.

-R, --recursive
List the attributes of all files and directories recursively.

-L, --logical
Logical walk, follow symbolic links to directories. The default behaviour is to follow symbolic link arguments unless --no-dereference is given, and to skip symbolic links encountered in subdirectories. Only effective in combination with -R.

-P, --physical
Physical walk, do not follow symbolic links to directories. This also skips symbolic link arguments. Only effective in combination with -R.

--version
Print the version of getfattr and exit.

--help
Print help explaining the command line options.

--
End of command line options. All remaining parameters are interpreted as file names, even if they start with a dash character.

getfattr 命令参数:


希望获取扩展 attr 属性的目标文件

getfattr 命令实例:


getfattr 查看文件 db_ck.sql 属性,默认没有设置任何扩展属性,该命令将不显示任何内容:

$ getfattr -d db_ck.sql 
$

可以使用 setfattr 命令将扩展属性设置为文件:

setfattr -n user.Name1 -v Value1 db_ck.sql 

设置扩展属性后,用 getfattr 命令将显示如下输出:

$ getfattr db_ck.sql 
$ file: db_ck.sql

user.Name1


$ getfattr -n user.Name1 db_ck.sql 
$ file: db_ck.sql

user.Name1="Value1"

getfattr 尝试获取不存在的 attr 属性:

$ getfattr -n user.Name2 db_ck.sql  

db_ck.sql: user.Name2: No such attribute

getfattr 只查看属性值:

$ getfattr --only-values db_ck.sql 

Value1

查看 getfattr 版本:

$ getfattr --version

getfattr 2.4.46

getfattr 命令扩展阅读:




getfattr 命令评论

共收录到 511Linux 命令