Linux Attributes Command

The lsattr and chattr commands in Linux are used to view and modify file attributes on a filesystem. These attributes provide additional control over how files are handled by the system.

lsattr Command

The lsattr command is used to list the attributes of files and directories.

Syntax:

lsattr [options] [file...]
    

Options:

Example:

To list attributes of a file:

lsattr myfile.txt

chattr Command

The chattr command is used to change the attributes of files and directories.

Syntax:

chattr [options] [attributes] [file...]
    

Options:

Attributes:

Example:

To make a file immutable:

chattr +i myfile.txt

Practical Example

To recursively list attributes of all files in a directory:

lsattr -R /path/to/directory

To remove the immutable attribute from a file:

chattr -i myfile.txt