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