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
-bash/zsh: setfattr 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/setfattr setfattr
setfattr 命令,设置文件系统对象的扩展属性,setfattr 命令相关联的新值与扩展属性名称,为每个指定的文件。
setfattr [-h] -n name [-v value] pathname... setfattr [-h] -x name pathname... setfattr [-h] --restore=file
-n name, --name=name Specifies the name of the extended attribute to set. -v value, --value=value Specifies the new value for the extended attribute. -x name, --remove=name Remove the named extended attribute entirely. -h, --no-dereference Do not follow symlinks. If pathname is a symbolic link, it is not followed, but is instead itself the inode being modified. --restore=file Restores extended attributes from file. The file must be in the format generated by the getfattr command with the --dump option. If a dash ( -) is given as the file name, setfattr reads from standard input. --version Print the version of setfattr 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.
希望设置扩展 attr 属性的目标文件
使用 setfattr
可以定义和设置自定义属性:
[root@localhost ~]$ setfattr -n user.example -v example anaconda-ks.cfg [root@localhost ~]$ getfattr -d anaconda-ks.cfg # file: anaconda-ks.cfg user.example="example"
setfattr 命令查看文件 md5 是否发生变化:
[root@localhost ~]$ md5sum anaconda-ks.cfg fda1aa550d3cf82423d1b1ad1ae53a13 anaconda-ks.cfg [root@localhost ~]$ setfattr -n user.md5sum -v fda1aa550d3cf82423d1b1ad1ae53a13 anaconda-ks.cfg [root@localhost ~]$ getfattr -d anaconda-ks.cfg # file: anaconda-ks.cfg user.example="example" user.md5sum="fda1aa550d3cf82423d1b1ad1ae53a13"