CHATTR(1)
โจ chattr โ the manual, but make it cute โจ
okay bestie, welcome to CHATTR(1), from the General Commands Manual. this is the one where we change file attributes on a Linux file system. it's giving "i own this inode and i said what i said." ๐ let's go.
๐ธ NAME ๐ธ
chattr โ change file attributes on a Linux file system. periodt.
๐ SYNOPSIS ๐
chattr [ -RVf ] [ -v version ] [ -p project ] [ mode ] files...
๐ฆ DESCRIPTION ๐ฆ
chattr changes the file attributes on a Linux file system. that's the whole vibe.
the format of a symbolic mode is +-=[aAcCdDeFijmPsStTux].
the operator + causes the selected attributes to be added to the existing attributes of the files; - causes them to be removed; and = causes them to be the only attributes that the files have. (yes, = is the "this is my whole personality now" operator. iconic.)
the letters aAcCdDeFijmPsStTux select the new attributes for the files, and here's the lineup bestie, no cap:
- append only (
a) - no atime updates (
A) - compressed (
c) - no copy on write (
C) - no dump (
d) - synchronous directory updates (
D) - extent format (
e) - case-insensitive directory lookups (
F) - immutable (
i) - data journaling (
j) - don't compress (
m) - project hierarchy (
P) - secure deletion (
s) - synchronous updates (
S) - no tail-merging (
t) - top of directory hierarchy (
T) - undeletable (
u) - direct access for files (
x)
the following attributes are read-only, and may be listed by lsattr(1) but not modified by chattr: encrypted (E), indexed directory (I), inline data (N), and verity (V). so you can look, but you cannot touch. respectfully. ๐ซถ
not all flags are supported or utilized by all file systems โ so go read the file system-specific man pages like btrfs(5), ext4(5), mkfs.f2fs(8), and xfs(5) for more file system-specific details. iykyk. ๐
โจ OPTIONS โจ
-Rโ recursively change attributes of directories and their contents. the whole tree gets the glow-up. ๐ณ-Vโ be verbose withchattr's output and print the program version. talkative and proud of it. ๐ฃ๏ธ-fโ suppress most error messages. what errors? we don't know her. ๐-v versionโ set the file's version/generation number.-p projectโ set the file's project number.
๐ ATTRIBUTES ๐
aโ a file with theaattribute set can only be opened in append mode for writing. only the superuser or a process possessing theCAP_LINUX_IMMUTABLEcapability can set or clear this attribute. main character lock-in energy. ๐Aโ when a file with theAattribute set is accessed, its atime record is not modified. this avoids a certain amount of disk I/O for laptop systems. your battery says thank you. ๐cโ a file with thecattribute set is automatically compressed on the disk by the kernel. a read from this file returns uncompressed data. a write to this file compresses data before storing them on the disk. Note: please make sure to read the bugs and limitations section at the end of this document. (Note: For btrfs, If thecflag is set, then theCflag cannot be set. Also conflicts with btrfs mount optionnodatasum.) ๐๏ธCโ a file with theCattribute set will not be subject to copy-on-write updates. this flag is only supported on file systems which perform copy-on-write. (Note: For btrfs, theCflag should be set on new or empty files. If it is set on a file which already has data blocks, it is undefined when the blocks assigned to the file will be fully stable. If theCflag is set on a directory, it will have no effect on the directory, but new files created in that directory will have theNo_COWattribute set. If theCflag is set, then thecflag cannot be set.)dโ a file with thedattribute set is not a candidate for backup when thedump(8)program is run. she's not on the roster for that. ๐ซDโ when a directory with theDattribute set is modified, the changes are written synchronously to the disk; this is equivalent to thedirsyncmount option applied to a subset of the files.eโ theeattribute indicates that the file is using extents for mapping the blocks on disk. it may not be removed usingchattr(1). read-only, bestie. ๐Eโ a file, directory, or symlink with theEattribute set is encrypted by the file system. this attribute may not be set or cleared usingchattr(1), although it can be displayed bylsattr(1). secretive. mysterious. we love her. ๐คซFโ a directory with theFattribute set indicates that all the path lookups inside that directory are made in a case-insensitive fashion. this attribute can only be changed in empty directories on file systems with the casefold feature enabled.iโ a file with theiattribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode. only the superuser or a process possessing theCAP_LINUX_IMMUTABLEcapability can set or clear this attribute. absolutely immovable. do not perceive her. ๐งIโ theIattribute is used by the htree code to indicate that a directory is being indexed using hashed trees. it may not be set or cleared usingchattr(1), although it can be displayed bylsattr(1).jโ a file with thejattribute has all of its data written to the ext3 or ext4 journal before being written to the file itself, if the file system is mounted with thedata=orderedordata=writebackoptions and the file system has a journal. when the file system is mounted with thedata=journaloption all file data is already journalled and this attribute has no effect. only the superuser or a process possessing theCAP_SYS_RESOURCEcapability can set or clear this attribute.mโ a file with themattribute is excluded from compression on file systems that support per-file compression.Nโ a file with theNattribute set indicates that the file has data stored inline, within the inode itself. it may not be set or cleared usingchattr(1), although it can be displayed bylsattr(1).Pโ a directory with thePattribute set will enforce a hierarchical structure for project id's. this means that files and directories created in the directory will inherit the project id of the directory, rename operations are constrained so when a file or directory is moved into another directory, that the project ids must match. in addition, a hard link to file can only be created when the project id for the file and the destination directory match. very structured. very organized. very that. ๐sโ when a file with thesattribute set is deleted, its blocks are zeroed and written back to the disk. Note: please make sure to read the bugs and limitations section at the end of this document. ๐โจSโ when a file with theSattribute set is modified, the changes are written synchronously to the disk; this is equivalent to thesyncmount option applied to a subset of the files.tโ a file with thetattribute will not have a partial block fragment at the end of the file merged with other files (for those file systems which support tail-merging). this is necessary for applications such asLILOwhich read the file system directly, and which don't understand tail-merged files. Note: as of this writing, the ext2, ext3, and ext4 file systems do not support tail-merging. so like. good luck out there. ๐ญTโ a directory with theTattribute will be deemed to be the top of directory hierarchies for the purposes of the Orlov block allocator. this is a hint to the block allocator used by ext3 and ext4 that the subdirectories under this directory are not related, and thus should be spread apart for allocation purposes. for example it is a very good idea to set theTattribute on the/homedirectory, so that/home/johnand/home/maryare placed into separate block groups. for directories where this attribute is not set, the Orlov block allocator will try to group subdirectories closer together where possible. friendship ended with clustering, now spreading apart is my best friend. ๐uโ when a file with theuattribute set is deleted, its contents are saved. this allows the user to ask for its undeletion. Note: please make sure to read the bugs and limitations section at the end of this document. ๐ซถxโ a file with thexrequests the use of direct access (dax) mode, if the kernel supports DAX. this can be overridden by thedax=nevermount option. for more information see the kernel documentation for dax: <https://www.kernel.org/doc/html/latest/filesystems/dax.html>.
if the attribute is set on an existing directory, it will be inherited by all files and subdirectories that are subsequently created in the directory. if an existing directory has contained some files and subdirectories, modifying the attribute on the parent directory doesn't change the attributes on these files and subdirectories. no retroactive glow-up, sorry. ๐
Vโ a file with theVattribute set has fs-verity enabled. it cannot be written to, and the file system will automatically verify all data read from it against a cryptographic hash that covers the entire file's contents, e.g. via a Merkle tree. this makes it possible to efficiently authenticate the file. this attribute may not be set or cleared usingchattr(1), although it can be displayed bylsattr(1). she verifies. she's verified. โญ
๐ง AUTHOR ๐ง
chattr was written by Remy Card <Remy.Card@linux.org>. it is currently being maintained by Theodore Ts'o <tytso@alum.mit.edu>. shoutout to the legends, fr fr. ๐
๐ BUGS AND LIMITATIONS ๐
okay this is the part where we get real, bestie. listen up.
the c, s, and u attributes are not honored by the ext2, ext3, and ext4 file systems as implemented in the current mainline Linux kernels. setting a and i attributes will not affect the ability to write to already existing file descriptors. so like. read this part, actually.
the j option is only useful for ext3 and ext4 file systems.
the D option is only useful on Linux kernel 2.5.19 and later. ancient kernel girlies, this one's not for you.
๐ AVAILABILITY ๐
chattr is part of the e2fsprogs package and is available from <http://e2fsprogs.sourceforge.net>. go get it, she's free. ๐
๐ SEE ALSO ๐
lsattr(1), btrfs(5), ext4(5), mkfs.f2fs(8), xfs(5). go read your siblings' manuals too, they miss you. ๐ซถ
and that's the whole page! this was E2fsprogs version 1.47.4, dated March 2025. slay, stay immutable, and don't forget to lsattr before you chattr. bye bestie!! ๐
โจ๐ธ๐ฆ๐
๐ฆ where this page comes from
- alpine 3.24: e2fsprogs-doc 1.47.4-r0 ยท GPL-2.0-or-later AND LGPL-2.0-or-later AND BSD-3-Clause AND MIT
- arch rolling: e2fsprogs 1.47.4-1 ยท GPL AND LGPL AND MIT
- nixpkgs unstable: e2fsprogs 1.47.4
- ubuntu stonking: e2fsprogs 1.47.4-1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms