Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the chattr command

2025-03-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to use the chattr command". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use the chattr command" can help you solve the problem.

The chattr command is used to change the attributes of a file, which can be queried by executing the lsattr instruction. This directive changes the properties of files or directories stored on the ext2 file system.

Common command parameters

A: Atime, which tells the system not to change the last access time to this file.

S: Sync, once the application performs a write operation on the file, the system immediately writes the modified results to disk.

A: Append Only, the system only allows data to be appended to this file, and no process is allowed to overwrite or truncate the file. If the directory has this property, the system will only allow files to be created and modified in this directory, not to delete any files.

B: the last access time of the file or directory is not updated.

C: compress the file or directory and store it.

D: when the dump program is executed, the file or directory will not be backed up by dump.

D: check for errors in the compressed file.

I: Immutable, the system does not allow any changes to this file. If the directory has this attribute, then any process can only modify the files under the directory and is not allowed to create and delete files.

S: delete the file completely and cannot be recovered because it is deleted from disk, and then populate the area where the file is located with 0.

U: when an application requests to delete the file, the system retains its data blocks so that the file can be deleted later to prevent accidental deletion of the file or directory.

T: the file system supports tail merge (tail-merging).

X: you can access the contents of the compressed file directly.

Display of commonly used commands

Chatter: locked files, cannot be deleted, cannot be changed

+ a: you can only add content to the file, but not delete it.

Chattr + a / etc/passwd

-d: cannot be deleted

Lock: chattr + I / etc/passwd files cannot be deleted, changed, or moved

View locking: the lsattr / etc/passwd file adds a parameter I for locking

Unlock: chattr-I / home/jiaxu/test.txt-means unlocked

Hide the chattr command: which chattrmv / usr/bin/chattr / opt/ftl/cd / opt/ftl/mv chattr h-- > change command Use alias h to hide identity / opt/ftl/h + I / home/jiaxu/test.txt-- > use h to drive chattr commands lsattr / home/jiaxu/test.txt-- > View encrypted information to recover hidden commands: mv h / usr/bin/chattrchattr-I / home/jiaxu/test.txtlsattr / home/jiaxu/test.txt this is the end of the introduction on "how to use the chattr command". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report