The invention discloses a method and a device for preventing files of a linux
file system from being deleted, and relates to the technical field of
cloud computing. Comprising the steps that 1, based on a linux
operating system, an anti-deletion configuration file is created, the configuration file is loaded into an
operating system kernel, configuration information is recorded through the configuration file, each item configuration information comprises a matching rule, each matching rule comprises a file path or a
regular expression, a protection strategy and priority information of the rule, and the file path or the
regular expression is matched with the protection strategy; checking grammar and validity of the matching rules and whether path and priority conflicts exist among the matching rules, and adding the matching rules checked to be correct into a rule set; 2, monitoring and intercepting any request for trying to delete the file, analyzing the path of the file requested to be deleted, reading the rule set, matching the path of the file requested to be deleted with the path of the file in the matching rule according to the priority from high to low, if the matching succeeds, executing the protection strategy, otherwise, allowing the
operating system to continue to execute the original deletion operation, and otherwise, executing the original deletion operation. And 3, displaying a deletion request for notifying the user of needing protection intervention, sending out warning information, and recording the behavior of trying to delete the protected file each time.