Protect File or Folder on Ubuntu/Linux

the necessity of protecting file or folder sometimes exist because we want to prevent file/folder operation from other user. in linux we can use chattr command

to show how this command works,

1. create new file
# touch newfile

2. add chattr command
# chattr +i newfile

3. try to remove file
# rm newfile
rm: cannot remove `newfile’: Operation not permitted

to remove “immutable” attribute just change option from +i to -i
4. remove attribute
# chattr -i newfile

now u should be able to remove the file.
use man chattr to find other possible options.

Leave a Reply

Your email address will not be published. Required fields are marked *