Combat: Create a file that cannot be deleted by root
Summary: View and modify the lowest (kernel level) properties of a Linux file
Command: Lsattr, chattr
Linux files, in addition to the basic permissions rwx, and special permissions (SUID, SGID, Sbit (Sticky)), there are several closer to the underlying files, we can view these properties through Lsattr, and through the chattr to modify these properties
Command format:
lsattr [-RVADV] [file]
-R #递归的列出文件夹中所有文件的属性
-V #查看lsattr版本
-a #查看list所有的文件, including hidden files
-D #列出目录的属性
-V #列出文件的版本号or代号
chattr [-RVF] [mode] [file]
-R #递归的列出文件夹中所有文件的属性
-V #查看chattr版本
-F #抑制大多数错误消息
-V #设置文件的版本号or代号
Example: Chattr +i a.txt
These properties include: ' Aaccddeijssttu ':
Append only (a), after setting this parameter, can only add data to the file, not delete, more for the server date file security, only root to set this property
No atime updates (A), file or directory Atime (access time) cannot be modified (modified), which can effectively prevent the occurrence of disk I/O errors such as laptops
Compressed (c), set whether the file is compressed and then stored. An automatic decompression operation is required for reading.
No copy on Write (C),
No dump (d), the setting file cannot be the backup target of the dump program
Synchronous directory Updates (D),
Extent Format (e),
Immutable (i), the settings file can not be deleted, renamed, set a connection relationship, and can not write or add content. The I parameter is useful for file system security settings.
Data journalling (j),
Secure deletion (s), the privacy of deleted files or directories, that is, hard disk space is fully recovered
Synchronous Updates (S), HDD I/O sync option, features like sync
No tail-merging (t),
Top of directory hierarchy (T),
and undeletable (U), in contrast to S, when set to U, the data content actually exists in the disk, can be used with undeletion.
Commonly used for a and I
Experiment: Add the I attribute to the/etc/passwd file and then modify it to perform operations such as
Eighth day 1-7 Combat: Create a file that cannot be deleted by root