Detailed description of chattr and lsattr commands

Source: Internet
Author: User
The chattr and lsattr commands explain the functions of the chattr commands. some of the functions are supported by the Linux kernel version. if the Linux kernel version is earlier than 2.2, many www.2cto.com functions cannot be implemented. Similarly, the function of-D to check for errors in the compressed file must be above 2.5.19... the chattr and lsattr commands explain the functions of the chattr commands. some of the functions are supported by the Linux kernel version. if the Linux kernel version is earlier than 2.2, many www.2cto.com functions cannot be implemented. Similarly, if-D is used to check the wrong function in the compressed file, the kernel 2.5.19 or later is required. In addition, modifying attributes using the chattr command can improve system security, but it is not suitable for all directories. The chattr command cannot protect the/,/dev,/tmp, and/var directories. Lsattr is relatively simple. it only displays the file attributes [root] # lsattr ---- ia --- j ---. the/lsattr_test commands are used to change the attributes of files and directories. compared with the chmod and ls commands, chmod only changes the read/write and execution permissions of files, the attribute control of www.2cto.com is changed by chattr. Usage of the chattr command: chattr [-RV] [-v version] [mode] files... the most important part is in the [mode] section. the [mode] section is composed of the +-= and [ASacDdIijsTtu] characters, which are used to control file attributes. +: Append parameters based on the original parameter settings. -: Remove the parameter based on the original parameter settings. =: Updated to the specified parameter settings. A: The atime (access time) of A file or directory cannot be modified, which can effectively prevent I/O errors on A laptop disk. S: Hard disk I/O synchronization option, similar to sync. A: append. after this parameter is set, data can only be added to the file, but cannot be deleted. This attribute is mostly used for server log file security and can only be set by root. C: compresse: specifies whether the file is compressed before being stored. Automatic decompression is required for reading. D: no dump. the file cannot be the backup target of the dump program. I: The set file cannot be deleted, renamed, or linked, and cannot be written or added. The I parameter is very helpful for security settings of the file system. J: That is, journal. this parameter is set so that when the file system is mounted by the mount parameter: data = ordered or data = writeback, the file is first recorded (in journal) when written ). If the filesystem parameter is set to data = journal, this parameter is automatically invalid. S: Confidential deletion of files or directories, that is, the hard disk space is all withdrawn. U: opposite to s. when set to u, the data content still exists in the disk and can be used for undeletion. a and I are often used in each parameter option. Option a can only be added and cannot be deleted. it is mostly used for security settings of the log system. I is a more rigorous security setting. this option can be applied only to processes with superuser (root) or CAP_LINUX_IMMUTABLE processing capability (identifier. Application example: 1. use the chattr command to prevent a key file from being modified in the system # chattr + I/etc/fstab and then try rm mv rename and other commands to operate on the file, result 2 of "Operation not permitted" is obtained. you can only append content to a file and cannot delete it. some log files are applicable to this Operation # chattr + a/data1/user_act.log
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.