Chattr (set file hiding attribute) command in CentOS
[Root @ linux ~] # Chattr [+-=] [ASacdistu] file or directory name
Parameters:
+: Add a special parameter. Other existing parameters do not change.
-: Remove a special parameter. Other existing parameters do not change.
=: It must be set and only the following parameters are available.
A: When the attribute A is set, the access time of the file (or directory) is atime (access)
It cannot be modified to avoid disk I/O Errors for portable computers!
S: This function is similar to the sync function! Data is synchronized to the disk!
This effectively prevents data loss!
A: When set to a, this file can only add data, but cannot be deleted, only root
This attribute can be set.
C: After this attribute is set, the file will be automatically compressed and automatically decompressed during reading,
However, during storage, data will be compressed before being stored (it seems useful for large files !)
D: When the dump (Backup) program is executed, setting the d attribute will make the file (or directory) not have the dump function
I: This is amazing! He can make an archive unable to be deleted, renamed, set links, or written
Or add new materials !』 Great help for system security!
J: when the file system format ext3 is used, setting the j attribute will record the file in
In journal! However, when the filesystem parameter is set to data = journalled
Log, so this attribute is invalid!
S: when the file sets the s parameter, it will be completely removed from the hard disk space.
U: opposite to s. When u is used to set the file, the data content still exists in the disk,
Can be used for undeletion.
Note: The above attribute settings are usually the set values of a and I, and many set values must be
Root can be set!
Example:
[Root @ linux ~] # Cd/tmp
[Root @ linux tmp] # touch attrtest
[Root @ linux tmp] # chattr + I attrtest
[Root @ linux tmp] # rm attrtest
Rm: remove write-protected regular empty file 'attrtest '? Y
Rm: cannot remove 'attrtest': Operation not permitted
# Have you seen it? Call! Even root cannot delete this file! Release settings!
[Root @ linux tmp] # chattr-I attrtest