1CHATTR(1) General Commands Manual CHATTR(1)
2
3
4
6 chattr - change file attributes on a Linux file system
7
9 chattr [ -RVf ] [ -v version ] [ mode ] files...
10
12 chattr changes the file attributes on a Linux file system.
13
14 The format of a symbolic mode is +-=[acdeijstuADST].
15
16 The operator `+' causes the selected attributes to be added to the
17 existing attributes of the files; `-' causes them to be removed; and
18 `=' causes them to be the only attributes that the files have.
19
20 The letters `acdeijstuADST' select the new attributes for the files:
21 append only (a), compressed (c), no dump (d), extent format (e),
22 immutable (i), data journalling (j), secure deletion (s), no tail-merg‐
23 ing (t), undeletable (u), no atime updates (A), synchronous directory
24 updates (D), synchronous updates (S), and top of directory hierarchy
25 (T).
26
27 The following attributes are read-only, and may be listed by lsattr(1)
28 but not modified by chattr: huge file (h), compression error (E),
29 indexed directory (I), compression raw access (X), and compressed dirty
30 file (Z).
31
33 -R Recursively change attributes of directories and their contents.
34
35 -V Be verbose with chattr's output and print the program version.
36
37 -f Suppress most error messages.
38
39 -v version
40 Set the file's version/generation number.
41
43 When a file with the 'A' attribute set is accessed, its atime record is
44 not modified. This avoids a certain amount of disk I/O for laptop sys‐
45 tems.
46
47 A file with the `a' attribute set can only be open in append mode for
48 writing. Only the superuser or a process possessing the
49 CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
50
51 A file with the `c' attribute set is automatically compressed on the
52 disk by the kernel. A read from this file returns uncompressed data.
53 A write to this file compresses data before storing them on the disk.
54 Note: please make sure to read the bugs and limitations section at the
55 end of this document.
56
57 When a directory with the `D' attribute set is modified, the changes
58 are written synchronously on the disk; this is equivalent to the
59 `dirsync' mount option applied to a subset of the files.
60
61 A file with the `d' attribute set is not candidate for backup when the
62 dump(8) program is run.
63
64 The 'E' attribute is used by the experimental compression patches to
65 indicate that a compressed file has a compression error. It may not be
66 set or reset using chattr(1), although it can be displayed by
67 lsattr(1).
68
69 The 'e' attribute indicates that the file is using extents for mapping
70 the blocks on disk. It may not be removed using chattr(1).
71
72 The 'I' attribute is used by the htree code to indicate that a direc‐
73 tory is being indexed using hashed trees. It may not be set or reset
74 using chattr(1), although it can be displayed by lsattr(1).
75
76 The 'h' attribute indicates the file is storing its blocks in units of
77 the filesystem blocksize instead of in units of sectors, and means that
78 the file is (or at one time was) larger than 2TB. It may not be set or
79 reset using chattr(1), although it can be displayed by lsattr(1).
80
81 A file with the `i' attribute cannot be modified: it cannot be deleted
82 or renamed, no link can be created to this file and no data can be
83 written to the file. Only the superuser or a process possessing the
84 CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
85
86 A file with the `j' attribute has all of its data written to the ext3
87 journal before being written to the file itself, if the filesystem is
88 mounted with the "data=ordered" or "data=writeback" options. When the
89 filesystem is mounted with the "data=journal" option all file data is
90 already journalled and this attribute has no effect. Only the supe‐
91 ruser or a process possessing the CAP_SYS_RESOURCE capability can set
92 or clear this attribute.
93
94 When a file with the `s' attribute set is deleted, its blocks are
95 zeroed and written back to the disk. Note: please make sure to read
96 the bugs and limitations section at the end of this document.
97
98 When a file with the `S' attribute set is modified, the changes are
99 written synchronously on the disk; this is equivalent to the `sync'
100 mount option applied to a subset of the files.
101
102 A directory with the 'T' attribute will be deemed to be the top of
103 directory hierarchies for the purposes of the Orlov block allocator.
104 This is a hint to the block allocator used by ext3 and ext4 that the
105 subdirectories under this directory are not related, and thus should be
106 spread apart for allocation purposes. For example it is a very good
107 idea to set the 'T' attribute on the /home directory, so that
108 /home/john and /home/mary are placed into separate block groups. For
109 directories where this attribute is not set, the Orlov block allocator
110 will try to group subdirectories closer together where possible.
111
112 A file with the 't' attribute will not have a partial block fragment at
113 the end of the file merged with other files (for those filesystems
114 which support tail-merging). This is necessary for applications such
115 as LILO which read the filesystem directly, and which don't understand
116 tail-merged files. Note: As of this writing, the ext2 or ext3 filesys‐
117 tems do not (yet, except in very experimental patches) support tail-
118 merging.
119
120 When a file with the `u' attribute set is deleted, its contents are
121 saved. This allows the user to ask for its undeletion. Note: please
122 make sure to read the bugs and limitations section at the end of this
123 document.
124
125 The 'X' attribute is used by the experimental compression patches to
126 indicate that a raw contents of a compressed file can be accessed
127 directly. It currently may not be set or reset using chattr(1),
128 although it can be displayed by lsattr(1).
129
130 The 'Z' attribute is used by the experimental compression patches to
131 indicate a compressed file is dirty. It may not be set or reset using
132 chattr(1), although it can be displayed by lsattr(1).
133
135 chattr was written by Remy Card <Remy.Card@linux.org>. It is currently
136 being maintained by Theodore Ts'o <tytso@alum.mit.edu>.
137
139 The `c', 's', and `u' attributes are not honored by the ext2 and ext3
140 filesystems as implemented in the current mainline Linux kernels.
141 These attributes may be implemented in future versions of the ext2 and
142 ext3 filesystems.
143
144 The `j' option is only useful if the filesystem is mounted as ext3.
145
146 The `D' option is only useful on Linux kernel 2.5.19 and later.
147
149 chattr is part of the e2fsprogs package and is available from
150 http://e2fsprogs.sourceforge.net.
151
153 lsattr(1)
154
155
156
157E2fsprogs version 1.41.12 May 2010 CHATTR(1)