"chattr" Command

Learn all about chattr command

HOME

chattr (Change Attribute) is a command that is used to set/unset certain attributes of files/folders in Linux/Unix system to secure accidental deletion or modification of important files and folders, even though you have full permission over files. root user only can change the file attributes.

root:~# man chattr
          

The operator + causes the selected attributes to be added to the existing attributes of the files.
The operator - causes the selected attributes to be removed.
The operator = causes to be the only attributes that the files have.

The letters acdeijstuACDST select the new attributes for the files: append only (a), compressed (c), no dump (d), extent format (e), immutable (i), data journalling (j), secure deletion (s), no tail-merging (t), undeletable (u), no Atime updates (A), no Copy on write (C), synchronous Directory updates (D), Synchronous updates (S), and Top of directory hierarchy (T).

The following attributes are read-only, and may be listed by lsattr command but not modified by chattr: huge file (h), compression Error (E), Indexed directory (I), compression raw access (X), and compressed dirty file (Z).

OPTIONS

-R Recursively change attributes of directories and their contents.

-V Be verbose with chattr's output and print the program version.

-f Suppress most error messages.