Configuration method for preventing file deletion for Linux system
Don't know how many times the file has been deleted
Especially on Linux systems, sometimes the delete command is executed, sometimes the synchronization command is executed, the file is gone
Let's start to set the method to prevent file deletion under Linux system. . .
The practical method is the chattr
command that comes with the Linux system.
The following chattr
configuration, in case some files are accidentally deleted. . . First understand some chattr
common commands
1
2
3
4
5
6
7
8
9
10
11
12
-R recursively change the attributes of a file, including any subfolders and any files below it
-V version information
-v set the version number of the file
mode instruction
"+ File Attributes" Set file attributes
"-File Attribute" Cancel File Attribute
"= File attribute" This file has this attribute only
File directive
a File can only be added, modified, and cannot be deleted
c folder add compressed files
s Safe delete
u cannot be deleted
1
2
chattr -V -R + a filename
The setting file can only be recursively added, modified, and cannot be deleted, and the execution process is displayed.
1
chattr -V -R -a filename