How to protect permissions on files under Linux

  

In Linux system operation, in order to prevent files from being changed, you can protect the files with permissions. How do you do this? The following small series will introduce you to the method of protecting the rights of files under Linux. Let's learn together.

In the process of managing Linux systems for some important key files, configuration files, and important personal information, users often do not want arbitrary changes, this time we need the file To protect the permissions to prevent tampering with the file, we can change the file's properties to 600.

Permission protection is set to 600 permissions

For example:

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

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

Using the <quo;chattr” command

In addition, if Linux is using ext2, ext3 or ext4 filesystems, you can also use the <quo;chattr” command:

code below :

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

Use the i attribute

to add i attributes to important files, even if the root user can not directly modify or delete such files, in order to effectively prevent accidental modification or deletion of files. The specific commands are as follows:

The code is as follows:

# chattr +i passwd

Add the attribute of i to the passwd file

Remove the i attribute using the following command :

The code is as follows:

# chattr –i passwd

Remove the properties of the passwd file i and modify the file.

The above is the way to protect the permissions of files under Linux. If some of your files are important, it is best to protect them. Otherwise, it will be troublesome.

Copyright © Windows knowledge All Rights Reserved