lsattr
List file attributes on a Linux second-extended filesystem
TLDR
Display the attributes of the files in the current directory
List the attributes of files in a particular path
List file attributes recursively in the current and subsequent directories
Show attributes of all the files in the current directory, including hidden ones
Display attributes of directories in the current directory
SYNOPSIS
lsattr [-RVadlv] [files...]
PARAMETERS
-a
List all files in directories, including those starting with '.'
-d
List directories only, not their contents
-l
Long listing format, similar to 'ls -l', showing attribute names
-R
Recurse into directories listing all files
-v
Display attribute version (numeric value)
-V
Print version information and exit
--help
Display help and exit
DESCRIPTION
lsattr displays the extended attributes set on files and directories using the chattr command on Linux second extended filesystems (ext2, ext3, ext4). These attributes control file behavior, such as making files immutable (cannot be modified or deleted), append-only (can only append data), or secure deletion. Attributes are stored in the file's inode and are visible only on supported filesystems.
By default, lsattr lists attributes for specified files or, if none, for all files in the current directory (excluding dotfiles). Attributes appear as uppercase letters after the filename, e.g., ----i--------e-- indicates immutable ('i') and no-dump ('d' would be shown, but 'e' is for extent format).
This tool is essential for system administrators to inspect and audit file protections, especially in security hardening or debugging scenarios. It requires read access to the inode, so root privileges may be needed for protected files. Note that attributes do not affect standard permissions but provide additional filesystem-level controls.
CAVEATS
Works only on ext2/ext3/ext4 filesystems; attributes ignored on others. Requires inode read access (may need root). Attributes shown as 40-character bitmask; not all bits user-settable.
COMMON ATTRIBUTES
a=append-only, c=compressed, d=no-dump, i=immutable, j=journaled, s=secure-delete, S=synchronous, t=no-tail-merge, u=undeletable.
EXAMPLE
lsattr /etc/passwd → -------------e-- /etc/passwd (extent format enabled).
HISTORY
Developed by Remy Card in 1992 for ext2 filesystem as part of e2fsprogs package. Evolved with ext3 (2001) and ext4 (2008) support, maintaining backward compatibility for attribute handling.


