Wednesday, January 4, 2012

Ubuntu: how to make a file or folder indelible and immutable

I do not know how many times have you ever accidentally delete a file or entire directories: A tragedy, right? If you do this manually, then you'll still find the trash files and folders ready to be restored, but if you are wrong to give a parameter to the command from the terminal rm (Which is there to remove file/directory), then the recovery is much more complicated. In order to prevent some of our important files or directories from being accidentally removed, changed or deleted, we can rely on chattr (change attribute), which has a parameter that is exactly our case, to prevent unpleasant incidents.


Making immutable/indelible a file

Open the terminal and type:
sudo chattr +i file_name
and the file "file_name" will become immutable. If instead you want to restore it, type:
sudo chattr -i file_name
Making immutable/indelible a folder

Open the terminal and type:
sudo chattr -R +i folder_name
and the folder "folder_name" become immutable. If instead you want to restore it, type:
sudo chattr -R -i path_of_the_directory
All very simple and useful, do not you think?
If this article was useful and you want to help us to grow Subscribing to our feed or Click "Like" in our Facebook page ,or follow us via Twitter or subscribing to our feed.

People who read this post also read :



0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More