Showing posts with label protect. Show all posts
Showing posts with label protect. Show all posts

Monday, January 20, 2014

Protect a file or a directory with Chattr command

0 comments

Protect a file or a directory with Chattr command

Chattr prevents changes to both, files and directories.

chattr +i <file>
It makes even root unable to make changes to the file and unable to delete It.

chattr +i <dir>
It make even root unable to change the content of the directory and unable to delete It.

chattr -R +i <dir>
It does the same as the previous one, but It applies to sub directories as well.

To make a file editable again, and a directory changeable :
sudo chattr -i <file that cannot be modified>

Example : 


I have a problem with Pacman. so I have edited /etc/resolv.conf, but my changes won't last long, because after disconnecting and connecting again, the file changes to Its default settings.

In my case I did some changes to the file and executed this command :
chattr +i /etc/resolv.conf

     
Read more...