File and Directory Information with stat Command
Discover how to utilize the stat command to retrieve comprehensive details about files and directories. Explore various options to display folder paths, user and group ownership, octal permissions, inode numbers, number of hard links, file types, total size, access, modification, and change times, I/O block size, and number of allocated blocks.
Print folder, user, group and octal permissions of all files in ~/
stat -c '%n %U %G %n %a' $HOME
Print permissions in octal
stat -c %a %n $HOME
Simulate Dolphin explorers default setup
stat -c '%n %s %U %G %a %z' $HOME/* \
|awk '//{printf "%10s %100s %10s %10s %10s %10s\n",$1,$2,$3,$4,$5,$6 }' \
|column -t -N Path,Size,User,Group,Perm,Modified \
|sed "1,2 i $(printf %85s\
|tr ' ' '=')"
Print the inode number
stat -c %i $HOME
Print the number of hard links
stat -c %h $HOME
Print the file type
stat -c %F $HOME
Print the file's total size in bytes
stat -c %s $HOME
Print the time of last access
stat -c %x $HOME
Print the time of last modification
stat -c %y $HOME
Print the time of last change
stat -c %z $HOME
Print the I/O block size
stat -c %o $HOME
Print the number of blocks allocated
stat -c %b $HOME