How to View Extended Attributes in Ubuntu Linux
This guide explains how to inspect metadata stored beyond standard permissions in Ubuntu. You will learn the specific command line tool required to display these attributes and how to install it if missing. By the end, you will know exactly how to retrieve extended file information.
The Command to Use
The command that reveals the extended attributes of a file in Ubuntu
is getfattr. This tool gets file extended attributes, which
are name-value pairs associated with inodes.
Installation
The utility is part of the attr package. If the command
is not found, install it using the following terminal command:
sudo apt update
sudo apt install attrBasic Usage
To view the extended attributes of a specific file, use the
-d flag to dump the values. Run the following syntax:
getfattr -d filenameReplace filename with the path to your target file. The
output will display the file path followed by any associated attribute
names and their values.
Common Options
-d: Dump all extended attributes associated with the file.-n name: Only get the specified attribute.-m pattern: Only get attributes matching the regular expression pattern.-R: Recursively get attributes for directories and their contents.
Note on lsattr
Do not confuse getfattr with lsattr. The
lsattr command lists file attributes on a second extended
filesystem (like ext2/ext3/ext4), such as immutable or append-only
flags, whereas getfattr handles generic extended attributes
used by various applications and security contexts like SELinux or
AppArmor.