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