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 +-=[aAcCdDeijsStTu].
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 'aAcCdDeijsStTu' select the new attributes for the files:
21 append only (a), no atime updates (A), compressed (c), no copy on write
22 (C), no dump (d), synchronous directory updates (D), extent format (e),
23 immutable (i), data journalling (j), secure deletion (s), synchronous
24 updates (S), no tail-merging (t), top of directory hierarchy (T), and
25 undeletable (u).
26
27 The following attributes are read-only, and may be listed by lsattr(1)
28 but not modified by chattr: compression error (E), huge file (h),
29 indexed directory (I), inline data (N), compression raw access (X), and
30 compressed dirty file (Z).
31
32 Not all flags are supported or utilized by all filesystems; refer to
33 filesystem-specific man pages such as btrfs(5), ext4(5), and xfs(5) for
34 more filesystem-specific details.
35
37 -R Recursively change attributes of directories and their contents.
38
39 -V Be verbose with chattr's output and print the program version.
40
41 -f Suppress most error messages.
42
43 -v version
44 Set the file's version/generation number.
45
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 When a file with the 'A' attribute set is accessed, its atime record is
52 not modified. This avoids a certain amount of disk I/O for laptop sys‐
53 tems.
54
55 A file with the 'c' attribute set is automatically compressed on the
56 disk by the kernel. A read from this file returns uncompressed data.
57 A write to this file compresses data before storing them on the disk.
58 Note: please make sure to read the bugs and limitations section at the
59 end of this document.
60
61 A file with the 'C' attribute set will not be subject to copy-on-write
62 updates. This flag is only supported on file systems which perform
63 copy-on-write. (Note: For btrfs, the 'C' flag should be set on new or
64 empty files. If it is set on a file which already has data blocks, it
65 is undefined when the blocks assigned to the file will be fully stable.
66 If the 'C' flag is set on a directory, it will have no effect on the
67 directory, but new files created in that directory will the No_COW
68 attribute.)
69
70 A file with the 'd' attribute set is not candidate for backup when the
71 dump(8) program is run.
72
73 When a directory with the 'D' attribute set is modified, the changes
74 are written synchronously on the disk; this is equivalent to the
75 'dirsync' mount option applied to a subset of the files.
76
77 The 'e' attribute indicates that the file is using extents for mapping
78 the blocks on disk. It may not be removed using chattr(1).
79
80 The 'E' attribute is used by the experimental compression patches to
81 indicate that a compressed file has a compression error. It may not be
82 set or reset using chattr(1), although it can be displayed by
83 lsattr(1).
84
85 The 'h' attribute indicates the file is storing its blocks in units of
86 the filesystem blocksize instead of in units of sectors, and means that
87 the file is (or at one time was) larger than 2TB. It may not be set or
88 reset using chattr(1), although it can be displayed by lsattr(1).
89
90 A file with the 'i' attribute cannot be modified: it cannot be deleted
91 or renamed, no link can be created to this file and no data can be
92 written to the file. Only the superuser or a process possessing the
93 CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
94
95 The 'I' attribute is used by the htree code to indicate that a direc‐
96 tory is being indexed using hashed trees. It may not be set or reset
97 using chattr(1), although it can be displayed by lsattr(1).
98
99 A file with the 'j' attribute has all of its data written to the ext3
100 or ext4 journal before being written to the file itself, if the
101 filesystem is mounted with the "data=ordered" or "data=writeback"
102 options. When the filesystem is mounted with the "data=journal" option
103 all file data is already journalled and this attribute has no effect.
104 Only the superuser or a process possessing the CAP_SYS_RESOURCE capa‐
105 bility can set or clear this attribute.
106
107 A file with the 'N' attribute set indicates that the file has data
108 stored inline, within the inode itself. It may not be set or reset
109 using chattr(1), although it can be displayed by lsattr(1).
110
111 When a file with the 's' attribute set is deleted, its blocks are
112 zeroed and written back to the disk. Note: please make sure to read
113 the bugs and limitations section at the end of this document.
114
115 When a file with the 'S' attribute set is modified, the changes are
116 written synchronously on the disk; this is equivalent to the 'sync'
117 mount option applied to a subset of the files.
118
119 A file with the 't' attribute will not have a partial block fragment at
120 the end of the file merged with other files (for those filesystems
121 which support tail-merging). This is necessary for applications such
122 as LILO which read the filesystem directly, and which don't understand
123 tail-merged files. Note: As of this writing, the ext2 or ext3 filesys‐
124 tems do not (yet, except in very experimental patches) support tail-
125 merging.
126
127 A directory with the 'T' attribute will be deemed to be the top of
128 directory hierarchies for the purposes of the Orlov block allocator.
129 This is a hint to the block allocator used by ext3 and ext4 that the
130 subdirectories under this directory are not related, and thus should be
131 spread apart for allocation purposes. For example it is a very good
132 idea to set the 'T' attribute on the /home directory, so that
133 /home/john and /home/mary are placed into separate block groups. For
134 directories where this attribute is not set, the Orlov block allocator
135 will try to group subdirectories closer together where possible.
136
137 When a file with the 'u' attribute set is deleted, its contents are
138 saved. This allows the user to ask for its undeletion. Note: please
139 make sure to read the bugs and limitations section at the end of this
140 document.
141
142 The 'X' attribute is used by the experimental compression patches to
143 indicate that the raw contents of a compressed file can be accessed
144 directly. It currently may not be set or reset using chattr(1),
145 although it can be displayed by lsattr(1).
146
147 The 'Z' attribute is used by the experimental compression patches to
148 indicate a compressed file is dirty. It may not be set or reset using
149 chattr(1), although it can be displayed by lsattr(1).
150
152 chattr was written by Remy Card <Remy.Card@linux.org>. It is currently
153 being maintained by Theodore Ts'o <tytso@alum.mit.edu>.
154
156 The 'c', 's', and 'u' attributes are not honored by the ext2, ext3,
157 and ext4 filesystems as implemented in the current mainline Linux ker‐
158 nels.
159
160 The 'j' option is only useful if the filesystem is mounted as ext3 or
161 ext4.
162
163 The 'D' option is only useful on Linux kernel 2.5.19 and later.
164
166 chattr is part of the e2fsprogs package and is available from
167 http://e2fsprogs.sourceforge.net.
168
170 lsattr(1), btrfs(5), ext4(5), xfs(5).
171
172
173
174E2fsprogs version 1.42.9 December 2013 CHATTR(1)