Linux - Stat (file or file system status)

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU) > Bash - File System

1 - About

stat display file (default) or file system status.

find uses it to collect its data.

File Status = File Metadata

The stat command is simply a frontend to the stat() system call. See the following man page

man 2 stat
Advertising

3 - Syntax

stat [OPTION] FILE...

where:

  • Through the --printf=FORMAT option a lot information are available, see the man page

4 - Data

  • Access - the last time the file was read
  • Modify - the last time the content of the file was modified
  • Change - the last time the meta data of the file was changed (e.g. permissions)

5 - Example

5.1 - File

stat testFile.txt
  File: `testFile.txt'
  Size: 4               Blocks: 8          IO Block: 4096   regular file
Device: ca02h/51714d    Inode: 2522975     Links: 1
Access: (0644/-rw-r--r--)  Uid: (  500/  oracle)   Gid: ( 1001/oinstall)
Access: 2015-09-15 13:50:26.000000000 +0200
Modify: 2015-09-15 12:43:18.000000000 +0200
Change: 2015-09-15 12:43:18.000000000 +0200

where:

Advertising

5.2 - File System

$ stat -f testFile.txt
  File: "testFile.txt"
    ID: f6b940611a2fbb15 Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 12427805   Free: 9800360    Available: 9159378
Inodes: Total: 12518912   Free: 12381458