Stop ignoring the immutable bit when you cannot delete files

Permissions & Security (Chmod/Chown/ACLs/SELinux/AppArmor)

Stop ignoring the immutable bit when you cannot delete files

🧩 The Challenge

Ever tried to nuke a configuration file or a log, only for root to be told permission denied? It drives me up the wall when you are definitely the superuser but the kernel still tells you to get lost.

💡 The Fix

The filesystem likely has the immutable attribute set, which prevents even root from touching the file until you strip it off. You need to check the attributes and flip them before you can do anything else.

lsattr /path/to/stubborn/file
chattr -i /path/to/stubborn/file
rm /path/to/stubborn/file

⚙️ Why It Works

This works because the immutable bit is a kernel-level protection that sits above standard POSIX permissions, making the file effectively read-only regardless of chmod or chown. You have to explicitly request that the filesystem drop that lock.

🚀 Pro-Tip: Use chattr +i on your critical shell scripts or sudoers files to keep your future self from accidentally blowing them away.

Linux Tips & Tricks | © ngelinux.com | 8/20/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted