Eighth Day 1-7 Combat: Create a file that cannot be deleted by root

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.