Most sysadmins reach for chmod when they want to lock down a file. The problem is that chmod 000 only changes the file’s permission bits; root can still override them. That’s where chattr comes in.
The chattr command lets you set and unset filesystem-level attributes on files and directories. These attributes are enforced at a lower level than traditional Unix permissions, giving you an additional layer of protection.
For example, chattr +i makes a file immutable: it cannot be modified, renamed, deleted, or replaced through normal filesystem operations, even by root. The attribute must be explicitly cleared with chattr -i before the file can be changed.