Interview Prep/Linux/Users, groups and access control

A team needs some files to be impossible to delete even by root accidentally, such as a critical config. How?

AdvancedScenarioUsers, groups and access control
Answer

Situation read → Extended file attributes.

What I'd do →

sudo chattr +i /etc/resolv.conf     # immutable
sudo chattr +a /var/log/audit.trail # append-only
lsattr /etc/resolv.conf

Remove with chattr -i before planned changes.

Why → The immutable flag blocks write, rename, delete and link even for root, until someone removes it with CAP_LINUX_IMMUTABLE.

Interview tip → It protects against mistakes and tools rewriting files, not against an attacker with root, who can just run chattr -i.

All Linux questions Roadmap: Linux

More on Users, groups and access control