Do not allow users to modify, delete files, etc., using chattr protection
usage of the chattr command: chattr [-RV] [-v version] [mode] files ...
Most crucially, in the [mode] section, the [mode] section is composed of +-= and [Asacddiijsttu] characters, which are used to control the file
Property.
+: The parameter is appended on the basis of the original parameter setting.
-: The parameters are removed based on the original parameter setting.
=: Updated to specify parameter settings.
A: Atime (Access time) of a file or directory cannot be modified (modified), which can effectively prevent the occurrence of disk I/O errors such as laptops.
S: HDD I/O sync option, similar to sync.
a : That is, append, after setting this parameter, you can only add data to the file, not delete, more for the server log file security, only root to set this property.
C : Compresse, sets whether the file is compressed and then stored. An automatic decompression operation is required for reading.
D : No dump, the settings file cannot be the backup target of the dump program.
I : The settings file cannot be deleted, renamed, linked, and cannot be written or added. The I parameter is useful for file system security settings.
J : That is journal, set this parameter so that when using the Mount parameter: data=ordered or Data=writeback hangs File system, files are recorded (in journal) when they are written. If the filesystem parameter is set to Data=journal, the parameter is automatically invalidated.
s : Delete files or directories confidentially, that is, the hard disk space is fully retracted.
u : In contrast to S, when set to U, the data content actually exists on disk and can be used for undeletion.
[Email protected]/]# chattr +i/etc/passwd
[Email protected]/]# chattr +i/etc/shadow
[Email protected]/]# chattr +i/etc/group
[Email protected]/]# chattr +i/etc/gshadow
[Email protected] ~]# Lsattr/etc/group/etc/passwd/etc/shadow/etc/gshadow
--i--–e-/etc/group
--i--–e-/etc/passwd
--i--–e-/etc/shadow
--i--–e-/etc/gshadow
If you need to change your password, do chattr-i remove permissions
[Email protected]/]# chattr-i/etc/passwd
[Email protected]/]# chattr-i/etc/shadow
[Email protected]/]# chattr-i/etc/group
[Email protected]/]# chattr-i/etc/gshadow
[Email protected] ~]# Lsattr/etc/group/etc/passwd/etc/shadow/etc/gshadow
————-e-/etc/group
————-e-/etc/passwd
————-e-/etc/shadow
————-e-/etc/gshadow
Change the permissions and then modify the file can, after the modification, then execute.
[Email protected]/]# chattr +i/etc/passwd
[Email protected]/]# chattr +i/etc/shadow
[Email protected]/]# chattr +i/etc/group
[Email protected]/]# chattr +i/etc/gshadow
Reprint: http://www.80uncle.com/linux%E6%96%87%E4%BB%B6%E6%9D%83%E9%99%90%E4%BF%9D%E6%8A%A4%E7%A6%81%E6%AD%A2%E7%94% A8%e6%88%b7%e4%bf%ae%e6%94%b9%e3%80%81%e5%88%a0%e9%99%a4%e3%80%81%e7%a7%bb%e5%8a%a8.html
Linux File Protection prohibits modification, deletion, movement of files, etc., using chattr +i protection