DEV Community

Nurul Islam Rimon
Nurul Islam Rimon

Posted on

šŸ” Secure Your Files with chattr +i in Linux

The chattr +i command makes a file immutable, meaning it can’t be edited, deleted, or renamed—even by root. Use it like this:

chattr +i filename
Enter fullscreen mode Exit fullscreen mode

To reverse it:

chattr -i filename
Enter fullscreen mode Exit fullscreen mode

It’s perfect for protecting system files or critical configs from accidental changes. Check attributes with:

lsattr filename
Enter fullscreen mode Exit fullscreen mode

Note: Only works on ext-based filesystems and requires root access. Use wisely to keep your Linux environment safe and stable.

Best Regards,
N I Rimon

Top comments (0)

OSZAR »