Using the Stat Command in Linux
Linux Stat Command
The Linux stat command allows you to view detailed information about files and directories. This can be useful if you want to quickly check the size, ownership, permissions, or modification times of a file or directory. The output from the stat command can also be used as input for other commands.
Syntax
The following is the basic syntax for the Linux stat command:
stat [options] [filename]
Options
-f
: displays the output in a format suitable for use in shell scripts-c
: displays the output in raw csv format-l
: displays the output in long format, showing more detailed information-t
: displays the output in a terse format, only showing the most important info-s
: displays only the size of the file or directory
Examples
To view detailed information about a file named "test.txt", you could run the following command:
stat test.txt
To view the size of the file in bytes, you could use the following command:
stat -s test.txt