The stat command is used to display detailed status of file, directory and file system in Linux.
Syntax: stat [options] FILE…
Example:
$ stat tmp/file1
Output:
File: tmp/file1
Size: 0 Blocks: 0 IO Block: 4096
Device: 12h/18d Inode: 3064192624 Links: 1
Access: (0660/-rw-rw—-) Uid: ( 0/ UNKNOWN) Gid: ( 1028/ UNKNOWN)
Access: 2015-02-28 15:39:03.000000000
Modify: 2015-02-28 15:39:03.000000000
Change: 2015-02-28 15:39:03.000000000
So, without options/arguments you can have the following details:
File | Size in Bytes |
Blocks | Number of blocks used |
IO Block | Size in bytes of every block |
Device | The identifier number of your storage device (harddrive, etc.) |
Inode | The inode number that the file or directory is linked to |
Access/Modify and change Times | Note that the timestamps also include which time zone that accesses or modifications took place in |
Arguments:
The following are some of the flags and arguments that can be used for the stat command:
Arguments | Details |
-f –filesystem | display filesystem status instead of file status |
-c –format | use the specified FORMAT instead of the default |
-L –dereference | follow links |
-Z –context | print the security context |
–help | display the help and exit |