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

Protection

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 :

touch file && mkdir directory
lsattr file
---------------- file

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

chattr +i file
chattr +i -R directory/

lsattr
----i----------- ./directory
----i----------- ./file

Now, we test this protection :

rm -rf directory/
rm: cannot remove ‘directory/’: Operation not permitted
mv directory/ directory_new
mv: cannot move ‘directory/’ to ‘directory_new’: Operation not permitted

rm file
rm: cannot remove ‘file’: Operation not permitted
mv file file_new
mv: cannot move ‘file’ to ‘file_new’: Operation not permitted

Release

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

chattr -i -R directory
chattr -i file

lsattr
---------------- ./directory
---------------- ./file