Securing Your Files: How to Prevent Deletion in Linux
Regarding the chattr
command, it is indeed a powerful tool in Linux for setting or unsetting file attributes, and it’s commonly used for protecting important files from unintended deletion or modification.
Protecting File in Linux terminal
# To protect a file $ sudo chattr +i abc.txt # Try to remove the file using rm command $ rm abc.txt
Removing Protection from File in Linux terminal
# To remove protection from the file $ sudo chattr -i abc.txt # Verify by attempting to remove the file again $ rm abc.txt