1CHATTR(1)                   General Commands Manual                  CHATTR(1)
2
3
4

NAME

6       chattr - change file attributes on a Linux file system
7

SYNOPSIS

9       chattr [ -RVf ] [ -v version ] [ -p project ] [ mode ] files...
10

DESCRIPTION

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 '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),  and
30       inline data (N).
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

OPTIONS

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

ATTRIBUTES

50       A  file  with the 'a' attribute set can only be open 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 candidate for backup when  the
74       dump(8) program is run.
75
76       When  a  directory  with the 'D' attribute set is modified, the changes
77       are written synchronously on  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       The 'E' attribute is used by the  experimental  encryption  patches  to
84       indicate  that the file has been encrypted.  It may not be set or reset
85       using 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  reset
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  reset
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 on 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 or ext3 filesys‐
135       tems do not (yet, except in very experimental  patches)  support  tail-
136       merging.
137
138       A  directory  with  the  'T'  attribute will be deemed to be the top of
139       directory hierarchies for the purposes of the  Orlov  block  allocator.
140       This  is  a  hint to the block allocator used by ext3 and ext4 that the
141       subdirectories under this directory are not related, and thus should be
142       spread  apart  for allocation purposes.   For example it is a very good
143       idea to  set  the  'T'  attribute  on  the  /home  directory,  so  that
144       /home/john  and  /home/mary are placed into separate block groups.  For
145       directories where this attribute is not set, the Orlov block  allocator
146       will try to group subdirectories closer together where possible.
147
148       When  a  file  with  the 'u' attribute set is deleted, its contents are
149       saved.  This allows the user to ask for its undeletion.   Note:  please
150       make  sure  to read the bugs and limitations section at the end of this
151       document.
152

AUTHOR

154       chattr was written by Remy Card <Remy.Card@linux.org>.  It is currently
155       being maintained by Theodore Ts'o <tytso@alum.mit.edu>.
156

BUGS AND LIMITATIONS

158       The  'c',  's',   and 'u' attributes are not honored by the ext2, ext3,
159       and ext4 filesystems as implemented in the current mainline Linux  ker‐
160       nels.   Setting  'a'  and 'i' attributes will not affect the ability to
161       write to already existing file descriptors.
162
163       The 'j' option is only useful for ext3 and ext4 file systems.
164
165       The 'D' option is only useful on Linux kernel 2.5.19 and later.
166

AVAILABILITY

168       chattr  is  part  of  the  e2fsprogs  package  and  is  available  from
169       http://e2fsprogs.sourceforge.net.
170

SEE ALSO

172       lsattr(1), btrfs(5), ext4(5), xfs(5).
173
174
175
176E2fsprogs version 1.45.3           July 2019                         CHATTR(1)
Impressum