immune your files and folders from accidental deletion.
December 18th, 2006 mysurface Posted in Admin, chattr, man, Misc, sudo | Hits: 28831 | 2 Comments »
Okay, when you accidentally type
rm LoveLetterFromJane.txt
Your file are gone, can’t resume it at trash, there are no trash, the document are important to you! Oh My God!! you smack your box!
In Linux, you can change attribute for your files and folders, to make it immune from accidental deletion, not even with root permission. To do this art, you need two things.
1. chattr
2. root access or sudo.
Let say I have a folder call “darling”
sudo chattr +i darling
By enable “immunity” (+i) to “darling”, the entire folder can’t be delete by just using rm even you are root. The files and sub folders inside “darling” can’t be delete as well. You cannot create files or sub folders in “darling” too.
If you want to change back to normal, take away her “immunity” (-i).
sudo chattr -i darling
Besides adding “immunity”, chattr can do more, read the full manual to know more.
man chattr







December 19th, 2006 at 5:31 pm
Great, except it doesn’t work. Might be because Im using reiserfs though.
December 19th, 2006 at 9:29 pm
Ops…. Sorry I should have mention it is for ext2 or ext3 file system.