blob: 932ef4bcf86ad3738372eb808e37bd9402a2f5b8 [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001.\" -*- nroff -*-
Theodore Ts'o74becf31997-04-26 14:37:06 +00002.TH CHATTR 1 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
Theodore Ts'o3839e651997-04-26 13:21:57 +00003.SH NAME
Theodore Ts'o4f858542009-05-30 12:34:28 -04004chattr \- change file attributes on a Linux file system
Theodore Ts'o3839e651997-04-26 13:21:57 +00005.SH SYNOPSIS
6.B chattr
7[
Theodore Ts'oe68594d2007-10-22 08:51:39 -04008.B \-RVf
Theodore Ts'o3839e651997-04-26 13:21:57 +00009]
10[
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +000011.B \-v
12.I version
Theodore Ts'o3839e651997-04-26 13:21:57 +000013]
14[
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +000015.I mode
Theodore Ts'o3839e651997-04-26 13:21:57 +000016]
17.I files...
18.SH DESCRIPTION
19.B chattr
Theodore Ts'o4f858542009-05-30 12:34:28 -040020changes the file attributes on a Linux file system.
Theodore Ts'o3839e651997-04-26 13:21:57 +000021.PP
JP Abgralle0ed7402014-03-19 19:08:39 -070022The format of a symbolic mode is +-=[acdeijstuACDST].
Theodore Ts'o3839e651997-04-26 13:21:57 +000023.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
JP Abgralle0ed7402014-03-19 19:08:39 -070028The letters `acdeijstuACDST' select the new attributes for the files:
Eric Sandeen312c2a42009-05-27 23:23:43 -050029append only (a), compressed (c), no dump (d), extent format (e), immutable (i),
JP Abgralle0ed7402014-03-19 19:08:39 -070030data 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).
Eric Sandeen312c2a42009-05-27 23:23:43 -050034.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).
Theodore Ts'o3839e651997-04-26 13:21:57 +000040.SH OPTIONS
41.TP
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +000042.B \-R
Theodore Ts'o3839e651997-04-26 13:21:57 +000043Recursively change attributes of directories and their contents.
44.TP
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +000045.B \-V
Theodore Ts'oa88fa0c1999-01-05 07:02:39 +000046Be verbose with chattr's output and print the program version.
Theodore Ts'o3839e651997-04-26 13:21:57 +000047.TP
Theodore Ts'oe68594d2007-10-22 08:51:39 -040048.B \-f
49Suppress most error messages.
50.TP
Theodore Ts'ocaf8ce41999-10-21 19:56:34 +000051.BI \-v " version"
Theodore Ts'oe1a0a3e2000-02-11 05:00:19 +000052Set the file's version/generation number.
Theodore Ts'of3db3561997-04-26 13:34:30 +000053.SH ATTRIBUTES
Theodore Ts'o5cfd7402002-06-28 10:47:24 -040054When a file with the 'A' attribute set is accessed, its atime record is
Theodore Ts'o583ccdc1997-05-09 03:06:31 +000055not modified. This avoids a certain amount of disk I/O for laptop
Theodore Ts'o2ecc6fe1997-04-29 17:57:00 +000056systems.
Theodore Ts'oa789d841998-03-30 01:20:55 +000057.PP
Theodore Ts'of3db3561997-04-26 13:34:30 +000058A file with the `a' attribute set can only be open in append mode for writing.
JP Abgralle0ed7402014-03-19 19:08:39 -070059Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE
Theodore Ts'o51f8f8d2002-11-08 20:02:21 -050060capability can set or clear this attribute.
Theodore Ts'oa789d841998-03-30 01:20:55 +000061.PP
Theodore Ts'of3db3561997-04-26 13:34:30 +000062A file with the `c' attribute set is automatically compressed on the disk
Theodore Ts'o51f8f8d2002-11-08 20:02:21 -050063by the kernel. A read from this file returns uncompressed data. A write to
JP Abgralle0ed7402014-03-19 19:08:39 -070064this file compresses data before storing them on the disk. Note: please
Theodore Ts'o1aa3d562005-12-31 01:04:40 -050065make sure to read the bugs and limitations section at the end of this
66document.
Theodore Ts'oa789d841998-03-30 01:20:55 +000067.PP
JP Abgralle0ed7402014-03-19 19:08:39 -070068A 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
Theodore Ts'o023d1112002-08-17 14:44:56 -040077When 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
Theodore Ts'of3db3561997-04-26 13:34:30 +000081A file with the `d' attribute set is not candidate for backup when the
82.BR dump (8)
83program is run.
Theodore Ts'oa789d841998-03-30 01:20:55 +000084.PP
JP Abgralle0ed7402014-03-19 19:08:39 -070085The 'E' attribute is used by the experimental compression patches to
Theodore Ts'o023d1112002-08-17 14:44:56 -040086indicate that a compressed file has a compression error. It may not be
JP Abgralle0ed7402014-03-19 19:08:39 -070087set or reset using
Theodore Ts'o023d1112002-08-17 14:44:56 -040088.BR chattr (1),
89although it can be displayed by
90.BR lsattr (1).
91.PP
Andreas Dilgera5e14ea2008-08-24 20:24:23 -040092The 'e' attribute indicates that the file is using extents for mapping
Aneesh Kumar K.V7c8da6e2009-01-06 12:07:14 +053093the blocks on disk. It may not be removed using
94.BR chattr (1).
Andreas Dilgera5e14ea2008-08-24 20:24:23 -040095.PP
Theodore Ts'o51f8f8d2002-11-08 20:02:21 -050096The 'I' attribute is used by the htree code to indicate that a directory
JP Abgralle0ed7402014-03-19 19:08:39 -070097is being indexed using hashed trees. It may not be set or reset using
Theodore Ts'o51f8f8d2002-11-08 20:02:21 -050098.BR chattr (1),
99although it can be displayed by
100.BR lsattr (1).
101.PP
Eric Sandeen312c2a42009-05-27 23:23:43 -0500102The 'h' attribute indicates the file is storing its blocks in units of the
Andreas Dilgera5e14ea2008-08-24 20:24:23 -0400103filesystem 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
Theodore Ts'of3db3561997-04-26 13:34:30 +0000109A 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
Theodore Ts'o77be4d22003-03-06 12:39:55 -0500111to the file. Only the superuser or a process possessing the
Theodore Ts'o51f8f8d2002-11-08 20:02:21 -0500112CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
Theodore Ts'oa789d841998-03-30 01:20:55 +0000113.PP
Theodore Ts'o9a718842000-12-31 13:48:12 +0000114A 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
Theodore Ts'o77be4d22003-03-06 12:39:55 -0500117filesystem is mounted with the "data=journal" option all file data
JP Abgralle0ed7402014-03-19 19:08:39 -0700118is already journalled and this attribute has no effect. Only
119the superuser or a process possessing the CAP_SYS_RESOURCE
Theodore Ts'o51f8f8d2002-11-08 20:02:21 -0500120capability can set or clear this attribute.
Theodore Ts'o9a718842000-12-31 13:48:12 +0000121.PP
Theodore Ts'o1aa3d562005-12-31 01:04:40 -0500122When 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.
Theodore Ts'oa789d841998-03-30 01:20:55 +0000125.PP
Theodore Ts'of3db3561997-04-26 13:34:30 +0000126When 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.
Theodore Ts'oa789d841998-03-30 01:20:55 +0000129.PP
JP Abgralle0ed7402014-03-19 19:08:39 -0700130A directory with the 'T' attribute will be deemed to be the top of
Theodore Ts'o27c3e532009-04-21 22:18:19 -0400131directory 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
Theodore Ts'o1384cc62009-06-02 09:02:39 -0400138group subdirectories closer together where possible.
Theodore Ts'o15f90112002-11-01 01:53:52 -0500139.PP
Theodore Ts'ob3f5b4c2001-11-05 19:22:02 -0500140A file with the 't' attribute will not have a partial block fragment at
Theodore Ts'ofc05eb02003-03-25 23:02:34 -0500141the end of the file merged with other files (for those filesystems which
JP Abgralle0ed7402014-03-19 19:08:39 -0700142support tail-merging). This is necessary for applications such as LILO
Theodore Ts'ofc05eb02003-03-25 23:02:34 -0500143which 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.
Theodore Ts'ob3f5b4c2001-11-05 19:22:02 -0500146.PP
Theodore Ts'o1aa3d562005-12-31 01:04:40 -0500147When 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.
Theodore Ts'oa789d841998-03-30 01:20:55 +0000151.PP
JP Abgralle0ed7402014-03-19 19:08:39 -0700152The 'X' attribute is used by the experimental compression patches to
Theodore Ts'o023d1112002-08-17 14:44:56 -0400153indicate that a raw contents of a compressed file can be accessed
JP Abgralle0ed7402014-03-19 19:08:39 -0700154directly. It currently may not be set or reset using
Theodore Ts'o023d1112002-08-17 14:44:56 -0400155.BR chattr (1),
156although it can be displayed by
157.BR lsattr (1).
158.PP
JP Abgralle0ed7402014-03-19 19:08:39 -0700159The 'Z' attribute is used by the experimental compression patches to
160indicate a compressed file is dirty. It may not be set or reset using
Theodore Ts'o023d1112002-08-17 14:44:56 -0400161.BR chattr (1),
162although it can be displayed by
163.BR lsattr (1).
164.PP
Theodore Ts'o3839e651997-04-26 13:21:57 +0000165.SH AUTHOR
166.B chattr
Theodore Ts'o2e5a1b92004-01-31 20:27:36 -0500167was written by Remy Card <Remy.Card@linux.org>. It is currently being
168maintained by Theodore Ts'o <tytso@alum.mit.edu>.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000169.SH BUGS AND LIMITATIONS
JP Abgralle0ed7402014-03-19 19:08:39 -0700170The `c', 's', and `u' attributes are not honored
171by the ext2, ext3, and ext4 filesystems as implemented in the current
172mainline Linux kernels.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000173.PP
Theodore Ts'o9a718842000-12-31 13:48:12 +0000174The `j' option is only useful if the filesystem is mounted as ext3.
Theodore Ts'o88372d52002-06-15 18:58:39 -0400175.PP
176The `D' option is only useful on Linux kernel 2.5.19 and later.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000177.SH AVAILABILITY
178.B chattr
Theodore Ts'o6d56d512001-05-12 15:46:21 +0000179is part of the e2fsprogs package and is available from
180http://e2fsprogs.sourceforge.net.
Theodore Ts'o3839e651997-04-26 13:21:57 +0000181.SH SEE ALSO
182.BR lsattr (1)