File and directory operations command (19) - 15.chattr

Linux chattr command is used to change file attributes.

The instructions may change stored on the ext2 file system file or directory attributes that total the following 8 modes:

  1. a: Let the file or directory is for additional uses.
  2. b: do not update the last access time of the file or directory.
  3. c: to store the file or directory compression.
  4. d: the file or directory exclude tilting operation.
  5. i: not any change on a file or directory.
  6. s: Confidentiality delete files or directories.
  7. S: Instant update a file or directory.
  8. u: prevent accidental erasure.

grammar

the chattr [- the RV ] [- V <version number>] [+ / - / = <attribute>] [file or directory ...]

parameter

  -R recursive processing, all files and subdirectories in the specified directory dealt with together.

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

  -V display process execution instruction.

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

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

  = <Attributes> Specify the file or directory attributes.

Examples

To prevent a critical system file is modified with the chattr command:

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, and additional data, but can not be deleted for a variety of log files:

chattr +a /var/log/messages

 

Guess you like

Origin www.cnblogs.com/pangzheng/p/11025503.html