How to make a file or a folder undeletable in Ubuntu
Here is an easy way to make a file or a folder undeletable even by root user in Ubuntu.
Making a folder undeletable
To make a folder undeletable run:
sudo chattr +i -R foldername
After that you can't delete, rename or do anything with this folder. But if you don't need this folder anymore or you've got to apply some changes to it run:
sudo chattr -i -R foldername
Making a file undeletable
To make a file undeletable run:
sudo chattr +i filename
To be able to change or delete the file run:
sudo chattr -i filename
-
Echy2012-10-16 22:00:34
If there are too many files, you can have an error message like "argument list too long" or other thing like that. So you can use |xargs for delete all files. Like
ls . |xargs -l rm -f
(in the directory need to be cleaned)
Got a comment?
All Rights Reserved.