How to set immutable/unchangeable files in Linux (using chattr)

  • Immutable flag: no renaming, no symbolic link creation, no execution, no writable, only superuser can unset the attribute
$ chattr +i file
$ lsattr file
----i--------e- file
$ > file
-bash: file: Permission denied

# same but for directories, recursive
$ chattr -R +i dir
rm -rf dir/
rm: cannot remove 'dir/': Operation not permitted
  • Append flag: can only be open in append mode for writing.
$ chattr +a anothefile
$ > anothefile
-bash: anothefile: Operation not permitted
$ >> anothefile

from 5 ‘chattr’ Commands to Make Important Files IMMUTABLE (Unchangeable) in Linux


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s