Permissions and owners
The lsattr command
Lists the special attributes of ext2, ext3 and ext4 files, such as immutable.
Most useful options
-RRecursive: also lists the attributes of folder contents-aIncludes files that start with a dot inside folders-dLists folders as files, without showing their contents-lPrints the attributes with long names instead of letters-pShows the file's project number-vShows the file's version or generation numberCopy-ready examples
$ lsattr -d Descargasattributes of the Descargas folder, without listing what it contains.$ lsattr -R proyecto/attributes of the folder and everything inside it.$ lsattr -a carpeta/includes the hidden files that start with a dot.$ lsattr -l /etc/resolv.conflong attribute names, easier to read than the letters.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| lsattr: No such file or directory while trying to stat noexiste | The file does not exist or the name is misspelled. | List the folder with ls and copy the exact name. |
| Usage: lsattr [-RVadlpv] [files...] | An option lsattr does not support was used. That line is the usage help. | Use only the options listed above, for example lsattr -R folder. |
Typical mistakes
- It ships with e2fsprogs and its manual covers ext2, ext3 and ext4. Other filesystems may support some of the attributes or fail when reading them.
- On a folder, lsattr lists its contents; with -d you see the folder itself.
- Without -a, files that start with a dot, such as .bashrc, do not appear.
Differences from similar commands
FAQ
How do I see the attributes of hidden files?
With lsattr -a folder/, which includes the ones that start with a dot.
Why does lsattr fail on a USB drive?
Because the drive usually has FAT or exFAT, which have no ext attributes. With lsblk -f you see the filesystem type of each partition.
What does each letter in the output mean?
Each letter is an attribute. Their meaning is in the chattr(1) page, which lsattr refers to.
More Permissions and owners commands
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course