Latest web development tutorials

Linux chattr Command

Linux command Daquan Linux command Daquan

Linux chattr command is used to change the file attributes.

This instruction can be changed is stored on the ext2 file system file or directory attributes, which are divided into the following 8 modes:

  1. a: the file or directory only make additional uses.
  2. b: do not update the last access time of the file or directory.
  3. c: After the file or directory will be stored compressed.
  4. d: exclude files or directories outside of the dumping operation.
  5. i: file or directory can not be any changes.
  6. s: Confidentiality delete files or directories.
  7. S: Instant update the file or directory.
  8. u: prevent outside deleted.

grammar

chattr [-RV][-v<版本编号>][+/-/=<属性>][文件或目录...]

parameter

-R Recursive processing, all files and subdirectories in the specified directory be dealt with.

-v <version number> settings file or directory versions.

-V Display process execution instruction.

+ <Properties> to open the file or directory attributes.

- <Property> to close the file or directory attributes.

= <Attribute> Specify the file or directory attributes.

Examples

With the chattr command to prevent a critical system files are modified:

chattr +i /etc/resolv.conf
lsattr /etc/resolv.conf

It will display the following attributes

----i-------- /etc/resolv.conf

So that a file can only be entered, additional data, but can not be deleted for a variety of log files:

chattr +a /var/log/messages

Linux command Daquan Linux command Daquan