文件的普通属性可以通过ls -l来查看,但还有一些“高级”的文件属性,可以通过chattr来设置、lsattr来查看。这些属性包括 文件是否被自动压缩、文件是否允许修改、删除等。简单的语法如下:
NAME
chattr - change file attributes on a Linux file system
SYNOPSIS
chattr [ -RVf ] [ -v version ] [ mode ] files...
DESCRIPTION
chattr changes the file attributes on a Linux file system.
The format of a symbolic mode is +-=[acdeijstuACDST].
ATTRIBUTES
When a file with the 'A' attribute set is accessed, its atime record is not modified. This avoids a certain amount of disk I/O for
laptop systems.
A file with the `a' attribute set can only be open in append mode for writing. Only the superuser or a process possessing the
CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
A file with the `c' attribute set is automatically compressed on the disk by the kernel. A read from this file returns uncompressed
data. A write to this file compresses data before storing them on the disk. Note: please make sure to read the bugs and limitations
section at the end of this document.
When a directory with the `D' attribute set is modified, the changes are written synchronously on the disk; this is equivalent to the
`dirsync' mount option applied to a subset of the files.
A file with the `d' attribute set is not candidate for backup when the dump(8) program is run.
A file with the `i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can
be written to the file. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
When a file with the `u' attribute set is deleted, its contents are saved. This allows the user to ask for its undeletion. Note:
please make sure to read the bugs and limitations section at the end of this document.