Inspect file attributes with lsattr

Check whether a file is immutable, append-only or undeletable before fighting with rm or chmod.

LinuxFilespermissionsattributesLow risk
Run lsattr file.txt to show attribute flags — an 'i' means immutable (nothing can change it) and 'a' means append-only.

01Command

Command
$ lsattr -a /etc/passwd

02What it does

ext4 and friends store per-file attributes beyond the classic permission bits: i (immutable), a (append-only), A (no atime updates), j (forced journaling) and more. lsattr prints them as a flag string, which is the first thing to check when rm, chmod or a write fails with 'Operation not permitted' even as root. The counterpart chattr sets or clears the flags.

03Risk

RiskLow risk
Requirementse2fsprogs package (preinstalled on distros using ext4). Only meaningful on ext2/ext3/ext4/xfs-style attributes; on tmpfs or NFS it errors or shows nothing.
!Warning: An immutable flag is the usual culprit when root cannot delete a file — clear it with sudo chattr -i file.txt (and re-set it after maintenance on files like /etc/resolv.conf that tools protect). lsattr on filesystems without attribute support fails, which does not mean the file is broken.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • lsattr(1) — Debian bookworm
    Debian Manpages · community · 2026-09-17
    Evidence: SYNOPSIS lsattr [ -RVadlpv ] [ files... ] — list file attributes on a second extended filesystem, with -a for hidden files too.
  • lsattr(1) — Arch Manual Pages
    Arch Linux · community · 2026-09-17
    Evidence: Same tool documented: lists the attributes of files on second extended filesystems, options -R -V -a -d.

Last verified: 2026-09-19 · Category: Files & Folders

06Related solutions