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

Explanation of chattr command under CentOS

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces "chattr command explanation under CentOS". In daily operation, I believe many people have doubts about chattr command explanation under CentOS. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "chattr command explanation under CentOS". Next, please follow the editor to study!

[root@linux ~] # chattr [+-=] [ASacdistu] file or directory name

Parameters:

+: add a special parameter, while other existing parameters remain unchanged.

-: remove a special parameter, while other existing parameters remain unchanged.

=: set a certain amount, and only have the following parameters

A: when the property An is set, the access time of this file (or directory) is atime (access)

Will not be modified, can avoid such as portable computer easy to have disk Icano error occurs!

S: this function is a bit similar to that of sync! Is to write the data synchronously to the disk!

Can effectively avoid data loss!

A: when an is set, this file can only add data, not delete it, only root

To set this property.

C: after this property is set, the file will be "compressed" automatically and will be automatically decompressed when it is read.

But when saving, it will be compressed before saving (it seems to be useful for large files!)

D: when the dump (backup) program is executed, setting the d attribute will make the file (or directory) not have the dump function

I: this I is very good! He can make a file "cannot be deleted, renamed, set links and cannot be written."

Or add new information! "it is of considerable help to system security!

J: when using the ext3 file system format, setting the j property will cause the file to be recorded in the

In journal! But when filesystem sets the parameter to data=journalled, because it has already been set

Log, so this property is invalid!

S: when the file sets the s parameter, it will be completely removed from the hard disk space.

U: in contrast to s, when u is used to set the file, the data content is actually stored on disk

Can be used to undeletion.

Note: above this property setting, the more common are the an and I settings, and many of the settings must be set as

Only root can set it!

Example:

[root@linux ~] # cd / tmp

[root@linux tmp] # touch attrtest

[root@linux tmp] # chattr + I attrtest

[root@linux tmp] # rm attrtest

Rm: remove write-protected regular empty file `attrtest'? Y

Rm: cannot remove `attrtest': Operation not permitted

# see? Whoo-hoo! Even root can't delete this file! Deactivate the settings!

[root@linux tmp] # chattr-I attrtest

At this point, the study of "explanation of chattr commands under CentOS" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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: 216

*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