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

The usage of the linux basic command chattr

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

Share

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

This article introduces the relevant knowledge of "the usage of the linux basic command chattr". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Chattr

Change the properties of the file, this command can only be used by superusers. This directive applies to ext2, ext3, ext4, xfs, ubifs, reiserfs, jfs systems. The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Chattr [- RVf] [- v version] + |-| = [attribute] file

The operator'+ 'causes the selected attributes to be added to the existing attributes of the file;'-'causes them to be deleted; and' = 'makes them the only attributes owned by the file.

2. List of options

Option

Description

-R

Modify the file attributes under the directory and its subdirectories recursively

-V

Show detailed execution process

-f

Skip error message

-v version

Set the version number of a file or directory

Attribute

Option

Description

A

Can only be opened in append mode

A

The last modification time is not recorded.

C

Compress the file, and when you read it, you get the decompressed data.

D

Synchronize directory updates

D

No backup

E

There is an error in the compressed file. This property cannot be manually modified by the user.

E

Files use extents to map to disk

-I

The directory is indexed using a hash tree, which cannot be manually modified by the user

H

The file size exceeds 2TB. This property cannot be manually modified by the user.

I

Files cannot be modified, but can be deleted or renamed

S

Clear the data block and save it to disk

S

Synchronize updates. After the file is modified, the result is written to disk

U

Prevent accidental deletion

-T

Top of the directory hierarchy

-X

Compress the original access. Although lsattr (1) can display it, it cannot currently be set or reset using chattr (1).

-Z

Compress dirty files. Although it can be displayed by lsattr (1), it cannot be set or reset using chattr (1)

3. Examples

1) add the an attribute and set the version number. Show detailed execution process

[root@192 weijie] # chattr-v 1-V + a 1.c

Chattr 1.41.12 (17-May-2010)

1.C the flag is set to-a mure-/ / the final result is shown here.

Version of 1.c set as 1

2) delete an attribute and add c attribute

[root@192 weijie] # chattr-Vv 2-a + c 1.c

Chattr 1.41.12 (17-May-2010)

1. The logo of c is set to-c Murray Murray-

Version of 1.c set as 2

This is the end of the introduction to "the usage of the linux basic command chattr". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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