Get the App
SLTechnology News&Howtos  ›  Servers  › 

The methods and steps of protecting the rights of files under Linux

Shulou Source: shulou.com Published: 2022-06-01 07:49:46 10月02日 Update

This article mainly explains "the methods and steps of protecting the rights of files under Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn the "Linux file rights protection methods and steps" it!

In the process of managing the Linux system, we often do not want users to modify some important key files, configuration files and important personal data at will. At this time, we need to protect the file from tampering with the file.

Permission protection is set to 600 permissions

For example:

[root@localhost /] # chmod 600 / usr/local/webserver/nginx/conf/nginx.conf

So we set the / usr/local/webserver/nginx/conf/nginx.conf file to 600 permissions to prevent modification.

Use the "chattr" command

Alternatively, if Linux is using an ext2, ext3, or ext4 file system, you can also use the "chattr" command:

The code is as follows:

Usage: chattr [- RVf] [- + = AacDdeijsSu] [- v version] files.

Use the I attribute

Add an I attribute to important files, and even root users cannot directly modify or delete such files to effectively prevent accidental modification or deletion of files. The specific commands are as follows:

The code is as follows:

# chattr + I passwd

Add an I attribute to the passwd file

Remove the I attribute using the following command:

The code is as follows:

# chattr-I passwd

Remove the attribute of the passwd file I and modify the file.

At this point, I believe you have a deeper understanding of the "methods and steps to protect files under Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Files permissions properties protection methods commands steps importance code content users systems learning practical deeper effective unexpected personal personal data key Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Linux OPPO Reno Docker Huawei