lsattr

image.png

文件属性依赖于具体文件系统如ext4、F2FS的支持。

e:文件inode使用了extents
a: Append only
c: Compressed
A: No atime updates. The atime is a value in an inode that records the last time a file was accessed.

C: No copy-on-write. If two processes request access to a file, they can be given pointers to the same file. They are only given their own unique copy of the file if they try to write to the file, making it unique to that process.

d: No dump. The Linux dump command is used to write copies of entire file systems to backup media. This attribute makes dump ignore the file. It is excluded from the backup.

D: Synchronous directory updates. 目录同步更新。When this attribute is turned on for a directory, all changes to that directory are written synchronously—that is, immediately—on the hard drive. Data operations can be buffered.数据操作可以被缓存。

e: Extent format. The e attribute indicates that the file system is using extents to map the location of the file on the hard drive. You cannot change this with chattr. It is a function of the operation of the file system.

i: Immutable. An immutable file cannot be modified, including renaming and deleting. The root user is the only person who can set or unset this attribute.

s: Secure deletion. When a file with this attribute set is deleted, the hard drive blocks that held the file data are overwritten with bytes containing zeroes. 文件被删除后,文件的数据块用0覆盖写。Note that this is not honored by the ext4 file system.

S: Synchronous updates. Changes to a file with its S attribute set are written to the file synchronously.文件同步更新,不走buffer write。

u: Deleting a file that has its u attribute set causes a copy of the file to be made. This can be beneficial to file recovery if the file was removed in error.
删除带u属性的文件,引发对这个文件的复制,用来错误删除文件时候的恢复。

chattr

chattr +a text-file.txt,增加append only属性
chattr -a text-file.txt,增加append only属性


Kevinི
1 声望0 粉丝

引用和评论

0 条评论