Understanding the command stat

The CentOS command line is full of tools, and trying to learn them all is perhaps a lifetime's work. As with all tasks, reaching the finish line begins with the first step. Our first step will be to delve into the world of the /usr/bin/stat command. By using this command, we can query a file's metadata. A file in CentOS consists of:

  • A filename (hard link)
  • File metadata (inode)
  • Data

Using stat and the filename alone, we can view the complete inode metadata. This is demonstrated with the following group of commands:

$ cd #move to your home directory
$ ls > my_newfile #list the contents and redirect the output to the new file
$ stat my_newfile #display the inode metadata

The following screenshot displays the output of ...

Get CentOS System Administration Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.