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 chattr command in linux system

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to use the chattr command in the linux system, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The chattr command is very useful, some of which are supported by the Linux kernel version, and if the Linux kernel version is less than 2.2, then many functions cannot be implemented. In addition, modifying properties through the chattr command can improve the security of the system, but it is not suitable for all directories.

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 restore hidden commands: mv h / usr/bin/chattrchattr-I / home/jiaxu/test.txtlsattr / home/jiaxu/test.txt is all the contents of this article entitled "how to use chattr commands in the linux system". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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