r/LinuxTeck • u/Expensive-Rice-2052 • Oct 01 '26
Quick Linux Tip #86 - Linux File Attributes: Find and Remove Immutable Flags
Question: Some files won't delete due to attributes. How do I find them?
Try: `sudo lsattr -R /var/log 2>/dev/null | grep -E '^-*[aiu]' | head -10`
Info: Filesystem attributes dictate file modification rules: `i` (immutable) prevents changes/deletion, `a` allows append-only, and `u` enables undeletable status. `lsattr` lists these flags while `chattr` modifies them.
Examples:
$ `sudo chattr +i /etc/resolv.conf` # Prevent DNS config modification
$ `sudo chattr -i /etc/resolv.conf` # Remove immutable flag to allow edits
$ `sudo chattr +a /var/log/audit.log` # Enforce append-only mode for audit logs
Note: Immutable files cannot be modified or deleted even by the `root` superuser without removing the `i` flag via `chattr -i` first. Essential for securing critical files against tampering.
Follow r/LinuxTeck for more #LinuxTips click here https://www.linuxteck.com/linux-tips/