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

Use the chattr command of linux to change file properties

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Do not know how to use linux's chattr command to change file properties? In fact, it is not difficult to solve this problem. Let the editor take you to learn how to solve it. I hope you will gain a lot after reading this article.

The chattr directive can change the file attributes of the linux file system. The common format is: +-= [aAcCdDeijsStTu]

"aAcCdDeijsStTu" represents new attributes that can be assigned to a file, and these attributes have the following modes.

A: let the file or directory be used for additional purposes only; A: when a file with "A" attribute is accessed, its atime record will not be modified; c: store the file or directory after compression; d: exclude the file or directory from the dumping operation; I: do not change the file or directory arbitrarily J: if the file system has the "data=order" or "data=writeback" options installed, the file with the "j" attribute writes all its data to the ext log before writing to the file itself; s: when the file with the "s" attribute set is deleted, its block is zeroed and written back to disk; S: when the file with the "S" attribute set is modified, the change is synchronously written to disk This is equivalent to the "synchronous" mount option applied to a subset of files; u: when you delete a file with a set of'u 'attributes, its contents are saved.

Syntax format: chattr [parameters] [file]

Practical parameters:

-R recursively processes all files under the directory-v sets the file or directory version-V displays the instruction execution + opens the attribute of the file or directory-closes the attribute of the file or directory = the attribute of the specified file or directory

Reference example

Use the chattr command to prevent a key file in the system from being modified (locked):

[root@linuxcool ~] # chattr + I / etc/resolv.conf

Unlock:

[root@linuxcool] # chattr-I / home/omd/h.txt

Let a file only append data to it, but not delete it. It applies to all kinds of log files:

[root@linuxcool ~] # chattr + a / var/log/messages Thank you for reading this article carefully. I hope the editor will share and use linux's chattr command to change the file properties. At the same time, I also hope you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

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

Servers

Wechat

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

12
Report