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.