File and Directory Information with stat Command
Learn how to use the stat command to retrieve detailed information about files and directories. Explore options to display folder, user, group, and octal permissions, as well as inode number, number of hard links, file type, total size, access/modification/change times, I/O block size, and number of allocated blocks. Optimize your file and directory management with these powerful stat command usages.
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