chattr
change file attributes on Linux filesystems
TLDR
Make immutable
SYNOPSIS
chattr [OPTIONS] [mode] files...
DESCRIPTION
chattr changes file attributes on Linux filesystems. These extended attributes provide security and administrative controls beyond standard permissions, such as making files immutable or append-only.
The immutable attribute (+i) is particularly useful for protecting critical system files, as even root cannot modify, delete, or rename an immutable file until the attribute is removed. The append-only attribute (+a) is commonly used for log files to prevent tampering while still allowing new entries to be written.
PARAMETERS
+attribute
Add attribute to file-attribute
Remove attribute from file=attribute
Set only the specified attributes-R
Change attributes recursivelyi
Immutable - cannot be modified, deleted, or renameda
Append-only - can only be appended tos
Secure deletion - blocks overwritten with zerosS
Synchronous updatesA
No atime updatesc
Compressede
Extent format (default on ext4)F
Case-fold directory (case-insensitive)
CAVEATS
Requires appropriate capabilities or root privileges. Immutable files cannot be changed even by root until the attribute is removed. Not all filesystems support all attributes.
HISTORY
chattr is part of e2fsprogs, providing extended attribute management for ext2/ext3/ext4 and other Linux filesystems.
