Thursday, April 29, 2010

Tornar arquivo nao deletavel ou somente incremental

Make Your Files Immutable Which Even Root Can't Delete
To make your file (test_file) immutable
# chattr +i test_file
You can only do it logged in as root. Here the +i option sets the immutable bit for the file. Once this bit is set, even root can't delete or tamper with the file.
If you want to unset the immutable flag, just run the following command:
# chattr -i test_file
You can check what are the attributes of a file by using the following command:
# lsattr test_file
----i-------- test_file
chattr can be used to set/unset many more file attributes. Like if you want to allow everybody to just append data to a file and not change already entered data, you can set the append bit as follows:
# chattr +a test_file
Now the test_file can only be opened in append mode for writing data. You can unset the append attribute as follows:
# chattr -a test_file
To know more about this very useful tool in the system administrator's forte, check the man page for chattr.

No comments:

Blog Archive