Apart from the file mode bits that control user and group read, write and execute permissions, several file systems support file attributes that enable further customization of allowable file operations.
Warning: By default, file attributes are not preserved by cp, rsync, and other similar programs.
The e2fsprogs package contains the programs lsattr(1) and chattr(1) that list and change a file's attributes, respectively.
These are a few useful attributes. Not all filesystems support every attribute.
a | append only: File can only be opened for appending. |
c | compressed: Enable filesystem-level compression for the file. |
i | immutable: Cannot be modified, deleted, renamed, linked to. Can only be set by root. |
j | data journaling: Use the journal for file data writes as well as metadata. |
m | no compression: Disable filesystem-level compression for the file. |
A | no atime update: The file's atime will not be modified. |
C | no copy on write: Disable copy-on-write, for filesystems that support it. |
See chattr(1) for a complete list of attributes and for more info on what each attribute does.
For example, if you want to set the immutable bit on some file, use the following command:
# chattr +i /path/to/file
To remove an attribute on a file just change + to -.