Name
chattr — stdin stdout - file -- opt --help --version
Synopsis
chattr [options
] [+ − =]attributes
[files
]
If you grew up with other Unix systems, you might be surprised
that Linux files can have additional attributes beyond their access
permissions. If a file is on an “ext” filesystem (ext2, ext3, etc.),
you can set these extended attributes with the chattr
(change attribute) command and list
them with lsattr
.
As with chmod
, attributes
may be added (+) or removed (-) relatively, or set absolutely (=).
For example, to keep a file compressed and nondumpable, run:
$ chattr +cd myfile
Attribute |
Meaning |
---|---|
|
Append-only: appends are permitted to this file, but it cannot otherwise be edited. Root only. |
|
Accesses not timestamped: accesses to this file don’t update its access timestamp (atime). |
|
Compressed: data is transparently compressed on writes and uncompressed on reads. |
|
Don’t dump: tell the
|
|
Immutable: file cannot be changed or deleted (root only). |
|
Journaled data (ext3 filesystems only). |
|
Secure deletion: if deleted, this file’s data is overwritten with zeroes. |
|
Synchronous update:
changes are written to disk immediately, as if you had typed
|
|
Undeletable: file cannot be deleted. |
There are a few other attributes too, some of them obscure or experimental. See the manpage for details.
Useful options
|
Get Linux Pocket Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.