Protect your files and directories from deletion on Linux

As an administrator, you can need to protect a file or a directory from deletion on your system.


It’s very easy to protect a file or directory if it uses these files system : Ext2, Ext3 or Ext4.
We create a new file and directory for a test :

We protect (from delete & rename) the file and directory with chattr command :

Now, we test this protection :


To delete this protection, you need to use chattr command :