Making a File Undeletable – Even By Root in Linux

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.

sudo chattr +i some.file

And recursively….

sudo chattr +i -RV /

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

sudo chattr -i some.file

About the author

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

Leave a Reply