How to get file and directory stat or information

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:

FileSize in Bytes
BlocksNumber of blocks used
IO BlockSize in bytes of every block
DeviceThe identifier number of your storage device (harddrive, etc.)
InodeThe inode number that the file or directory is linked to
Access/Modify and change TimesNote 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:

ArgumentsDetails
-f  –filesystemdisplay filesystem status instead of file status
-c   –formatuse the specified FORMAT instead of the default
-L  –dereferencefollow links
-Z   –contextprint the security context
–helpdisplay the help and exit

Leave a Reply

Your email address will not be published. Required fields are marked *