Use low-level filesystem attributes to prevent modifications and deletions with a single command. 16.11.2025 | reading time: 2 min When a simple permission change is not enough, `chattr` sets low-level filesystem attributes such as immutable and append-only so a file cannot be changed or removed; this lesson shows commands and real outputs so he can apply the protection immediately. Hands-on: lock a config file Create and inspect a file: `echo "do not touch" > secret.txt`; check attributes: `lsattr secret.txt` -> `------------- secret.txt`; set immutable: `sudo chattr +i secret.txt`; attempt removal: `rm secret.txt` -> `rm: cannot remove 'secret.txt': Operation not permitted`; confirm attribute: `lsattr secret.txt` -> `----i--------e-- secret.txt`; to remove later run `sudo chattr -i secret.txt` and then `rm secret.txt` will succeed. Other powerful attributes `+i` is the headline, but `+a` (append-only) is also useful for logs, `+A` disables atime updates and reduces writes, and attributes can be set recursively with `chattr -R`; remember that attributes are enforced by the filesystem so support varies and only root can change them. Commands that belong together Use `lsattr` to inspect attributes, `chattr` to change them and `setfattr`/`getfattr` for extended attributes; also check filesystem tools such as `tune2fs` and read `man chattr` because behavior differs across ext2/3/4 and other filesystems. Where to go from here Practice protecting different file types and directories, test how backup and restore handle attributes, and then explore broader Linux administration topics; consider exam preparation like CompTIA Linux+ or LPIC-1 with intensive training at bitsandbytes.academy to turn hands-on skills into certification. Join Bits & Bytes Academy First class LINUX exam preparation. filesystem security utilities backup