attr 中文man页面

系统
attr命令:用来设置XFS文件系统的扩展属性

attr[必要参数][属性名称][选择参数][路径名]

功能

attr命令:用来设置XFS文件系统的扩展属性

类似命令: getfattr  setfattr   xfsdump

相似命令: linux命令

执行权限: 超级用户普通用户

命令属性:文件管理

参数

必要参数

-s设置属性值

-g获取属性值

-r删除相关属性

-L如果指定“-L”参数并且对象是一个符号链接,那么操作是引用符号链接的对象的属性,如果不指定这个参数,那么操作是符号链接本身

-R如果“-R”参数指定并且处理过程拥有适当的特权,操作将发生在root用户的属性空间,而不是一般用户的属性空间

-q如果“-q”参数设定,属性保持安静,将不打印状态信息

选择参数

-V<属性值>设置属性值

范例

范例1:设置文件属性

root@snail-9linux:~#attr-sattrnamepathname//设置文件属性

root@snail-9linux:~#attr-gattrnamepathname//获取文件的属性

root@snail-9linux:~#attr-rattrnamepathname//移除文件的属性

#p#

NAME

attr - Extended attributes  

DESCRIPTION

Extended attributes are name:value pairs associated permanently with files and directories, similar to the environment strings associated with a process. An attribute may be defined or undefined. If it is defined, its value may be empty or non-empty.

Extended attributes are extensions to the normal attributes which are associated with all inodes in the system (i.e. the stat(2) data). They are often used to provide additional functionality to a filesystem - for example, additional security features such as Access Control Lists (ACLs) may be implemented using extended attributes.

Users with search access to a file or directory may retrieve a list of attribute names defined for that file or directory.

Extended attributes are accessed as atomic objects. Reading retrieves the whole value of an attribute and stores it in a buffer. Writing replaces any previous value with the new value.

Space consumed for extended attributes is counted towards the disk quotas of the file owner and file group.

Currently, support for extended attributes is implemented on Linux by the ext2, ext3 and XFS filesystem patches, which can be downloaded from http://acl.bestbits.at/ and http://oss.sgi.com/projects/xfs/ respectively.  

EXTENDED ATTRIBUTE NAMESPACES

Attribute names are zero-terminated strings. The attribute name is always specified in the fully qualified namespace.attribute form, eg. user.mime_type, trusted.md5sum, system.posix_acl_access, or security.selinux.

The namespace mechanism is used to define different classes of extended attributes. These different classes exist for several reasons, e.g. the permissions and capabilities required for manipulating extended attributes of one namespace may differ to another.

Currently the security, system, trusted, and user extended attribute classes are defined as described below. Additional classes may be added in the future.  

Extended security attributes

The security attribute namespace is used by kernel security modules, such as Security Enhanced Linux. Read and write access permissions to security attributes depend on the policy implemented for each security attribute by the security module. When no security module is loaded, all processes have read access to extended security attributes, and write access is limited to processes that have the CAP_SYS_ADMIN capability.  

Extended system attributes

Extended system attributes are used by the kernel to store system objects such as Access Control Lists and Capabilities. Read and write access permissions to system attributes depend on the policy implemented for each system attribute implemented by filesystems in the kernel.  

Trusted extended attributes

Trusted extended attributes are visible and accessible only to processes that have the CAP_SYS_ADMIN capability (the super user usually has this capability). Attributes in this class are used to implement mechanisms in user space (i.e., outside the kernel) which keep information in extended attributes to which ordinary processes should not have access.  

Extended user attributes

Extended user attributes may be assigned to files and directories for storing arbitrary additional information such as the mime type, character set or encoding of a file. The access permissions for user attributes are defined by the file permission bits.

The file permission bits of regular files and directories are interpreted differently from the file permission bits of special files and symbolic links. For regular files and directories the file permission bits define access to the file's contents, while for device special files they define access to the device described by the special file. The file permissions of symbolic links are not used in access checks. These differences would allow users to consume filesystem resources in a way not controllable by disk quotas for group or world writable special files and directories.

For this reason, extended user attributes are only allowed for regular files and directories, and access to extended user attributes is restricted to the owner and to users with appropriate capabilities for directories with the sticky bit set (see the chmod(1) manual page for an explanation of Sticky Directories).  

FILESYSTEM DIFFERENCES

The kernel and the filesystem may place limits on the maximum number and size of extended attributes that can be associated with a file.

In the current ext2 and ext3 filesystem implementations, all extended attributes must fit on a single filesystem block (1024, 2048 or 4096 bytes, depending on the block size specified when the filesystem was created). This limit may be removed in a future version.

In the XFS filesystem implementation, there is no practical limit on the number of extended attributes associated with a file, and the algorithms used to store extended attribute information on disk are scalable (stored either inline in the inode, as an extent, or in a B+ tree).  

ADDITIONAL NOTES

Since the filesystems on which extended attributes are stored might also be used on architectures with a different byte order and machine word size, care should be taken to store attribute values in an architecture independent format.  

AUTHORS

Andreas Gruenbacher, <a.gruenbacher@computer.org> and the SGI XFS development team, <linux-xfs@oss.sgi.com>.  

SEE ALSO

getfattr(1), setfattr(1).

责任编辑:韩亚珊 来源: 互联网
相关推荐

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-11-01 13:46:50

中文mantac

2011-08-25 16:55:26

gets中文man

2011-08-25 15:49:02

freopen中文man

2011-08-25 16:00:56

fflush中文man

2011-08-25 16:08:55

fsetpos中文man

2011-08-25 15:33:18

exit中文man

2011-08-24 17:19:00

raw中文man

2011-08-25 10:55:37

services中文man

2011-08-25 09:35:26

units中文man

2011-08-24 13:57:35

DECLARE中文man

2011-08-11 15:28:43

ali中文man

2011-08-23 17:24:11

userdel中文man

2011-08-23 17:33:22

rdev中文man

2011-08-23 18:05:21

ABORT中文man

2011-08-18 19:15:25

group中文man

2011-08-23 10:17:54

bdflush中文man
点赞
收藏

51CTO技术栈公众号