stat [OPTION]... FILE...
Introduction
stat
command displays file or file system status.
Options
Here are some of the options that you will use the most:
-L
,--dereference
: follow links-f
,--file-system
: display file system status instead of file status-c --format=FORMAT
: use the specifiedFORMAT
instead of the default.
output a newline after each use ofFORMAT
--printf=FORMAT
: interpret backslash escapes, and do not output a mandatory trailing newline.
if you want a newline, include\n
inFORMAT
-t
,--terse
: print the information in terse form
The valid format sequences for files (without --file-system
) are so many that I suggest you to look for the official documentation to see them all.
Examples
Without any parameters, stat
command displays the default output: file size and type, device type, inode number, UID
, GID
, number of links and access/modification dates of the file.
stat my-file.txt
File: my-file.txt
Size: 26 Blocks: 8 IO Block: 4096 regular file
Device: 10302h/66306d Inode: 15208760 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ pit) Gid: ( 1000/ pit)
Access: 2022-06-02 12:21:00.264595989 +0200
Modify: 2021-11-28 12:54:55.057498677 +0100
Change: 2022-01-30 00:10:19.688493688 +0100
Birth: -
Check the filesystem status by using the -f
option as shown below:
stat --file-system Documents/
File: "Documents/"
ID: 37eab0e240a4b3a1 Namelen: 255 Type: ext2/ext3
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 122672878 Free: 70186800 Available: 63937930
Inodes: Total: 31227904 Free: 28939751
To only display inode and UID of a file, you need to use %i
and %u
format sequences inside FORMAT
string for --printf
option.
Please Note: \t
print a tab (8 spaces) and \n
print a new line.
stat --printf='%i\t%u\n' wifi-pwd.txt
15208760 1000
Quotes
Manual reference: