Home>Article>Operation and Maintenance> How to set linux not to allow permission changes
In Linux, you can use the chattr command to set permissions that are not allowed to be changed. This command is used to change file attributes. When the attribute is set to "i", it means that the file or directory must not be changed arbitrarily, that is, it is set Changing permissions is not allowed, the syntax is "chattr u i file or directory".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
Linux chattr command is used to change file attributes.
This command can change the attributes of files or directories stored on the ext2 file system. These attributes have the following 8 modes:
a: Make the file or directory only for additional purposes.
b: Do not update the last access time of the file or directory.
c: Compress the file or directory and store it.
d: Exclude files or directories from dumping operations.
i: Files or directories are not allowed to be changed arbitrarily.
s: Confidentially delete files or directories.
S: Update files or directories instantly.
u: Prevent accidental deletion.
Syntax
chattr [-RV][-v<版本编号>][+/-/=<属性>][文件或目录...]
Parameters
-R Recursive processing, processing all files and subdirectories in the specified directory together.
-v
-V displays the instruction execution process.
-
=
Examples are as follows:
i: Permissions cannot be modified
Example: chattr u i filename (corresponding folder), then the filename file cannot be modified by anyone, no matter who , if you need to modify it, you need to delete the i permission first, just use chattr -i filename. Check whether the i permission is set on the file using lsattr filename.
First, we use xshell to see if we have i permission. lsattr filename. as the picture shows.
Next, remove the i permission and enter in xshell, chattr -i filename. as the picture shows.
At this time, there is no prompt, but the modification has been successful. Then I went to xftp to modify the permissions and found that it was easy. Usually, in order to prevent files or websites from being invaded by others, we can also add i permissions. Enter in xshell, chattr i filename. as the picture shows. There is also no prompt, but it has been successful.
Recommended learning:Linux video tutorial
The above is the detailed content of How to set linux not to allow permission changes. For more information, please follow other related articles on the PHP Chinese website!