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:

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

You may want to see
How to sort contents of a file

The sort command is used to sort the contents of a file. You can sort the data in a text Read more

How to use sed command in Linux

sed, short for "stream editor", allows you to filter and transform text. A stream editor is used to perform basic Read more

How to use crontab in Linux

Cron is the system process that will automatically perform tasks for you according to a set schedule. The schedule is Read more

How to extract archive file in Linux

To extract archive file in Linux, you can use the tar command, used for extracting content from the archive files. "tar" Read more

Leave a Reply

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