Linuxstar
Published on

lsattr command-show file hidden attributes

Jonas

Jonas

1 min read

The full English name of the lsattr command is "list attribute", which is used to view the unique attribute information of a specific device or specific file on the Linux second extended file system. This command is often used with chattr. The chattr command is used to change the hidden attributes of a file or directory, and the lsattr command is used to view its attributes.

Syntax: lsattr [parameter] [file]

Command parameters
-a  List all files in the directory, including hidden files
-d  Only show directory name
-R Recursively process all files and subdirectories in the specified directory
-v  Show file or directory version
-V Display version information
-D Display the name and default value of the attribute
-E Display the current value of the attribute obtained from the user device database

Reference example:

Use the lsattr command to display file attributes:

[root@linuxstar ~]# lsattr /etc/resolv.conf 

Display the current effective value of device en0:

[root@linuxstar ~]# lsattr -E -H -l en0  

Display the value of eno's arp attribute:

[root@linuxstar ~]# lsattr -R -l en0 -a arp

To display the current attribute values ​​of the rmt0 tape device:

[root@linuxstar ~]# lsattr -l rmt0 -E 

To display the default attribute values ​​of the rmt0 tape device:

[root@linuxstar ~]# lsattr -l rmt0 -D