Making a File Undeletable – Even By Root in Linux

Last Updated on

In some instances you may wish to have a file with permissions that restrict it from being removed by any user, even root.  This can be accomplished with the +i flag on the chattr command – chattr changes the file attributes on a Linux file system.

1
sudo chattr +i some.file

And recursively….

1
sudo chattr +i -RV /some.directory/

To remove the non-delete flag, simply use “-i” with the chattr command:

1
sudo chattr -i some.file
Lima

About the author

Lima is the visual nautical indicator for "stop instantly."

Leave a Reply