Question: Some files won't delete due to attributes. How do I find Linux file attributes?
Try: sudo lsattr -R /var/log 2>/dev/null | grep -E '^-*[aiu]' | head -10
Info: Linux file attributes control how files can be modified or deleted. The i attribute makes a file immutable, a enables append-only access, and u enables undeletable status. lsattr lists these attributes 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. Check Linux file attributes before troubleshooting files that appear impossible to modify or delete.
Follow @LinuxTeck for more #LinuxTips
Leave a Reply