How to Use the chattr command to protect important files from being deleted (1)

Source: Internet
Author: User

There are many tools and methods available on the market to protect your files and folders, so as not to be accidentally deleted. The chattr command is one of them. This command line utility can change the file attributes on the ext2/ext3/ext4 file system. It prevents important files from being accidentally deleted. Even if you have full permissions on files, you still cannot delete these files if they are protected by chattr.

Syntax

# Chattr [Operator] [parameter optimizer] [file name]

Operator

+ Add the selected attribute to the existing attribute of the file;-delete the selected Attribute; = make the selected attribute a unique attribute of the file.

Parameter Option

R -- recursively modify the attributes of a folder and its content. A -- files with the "a" attribute can only be opened in append mode for write operations. This attribute can be set or cleared only by a super user or a process that has the CAP_LINUX_IMMUTABLE function. I -- a file with the "I" attribute cannot be modified: the file cannot be deleted or renamed, a link cannot be created for the file, and data cannot be written to the file. This attribute can be set or cleared only by a super user or a process that has the CAP_LINUX_IMMUTABLE function.

The difference between the parameter option "a" and "I" is that files with the "a" attribute can append content, while files with the "I" attribute cannot Append content. You can use the lsattr command to view the file attributes.


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.