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