Stat: Detailed information about a file

Written by Benjamin Cane on 2012-05-24 | 1 min read

Stat is a command that I never knew about until somewhat recently but afterwards have had more and more reasons to use it. When run against a file stat will show detailed information about the file, this information can be extremely useful and I want to highlight some of the information I've found useful from stat.

$ stat rsync.out
   File: `rsync.out'
   Size: 696506     Blocks: 1368       IO Block: 4096   regular file
 Device: fc00h/64512d   Inode: 13862       <strong>Links: 1</strong>
 Access: (0644/-rw-r--r--)  Uid: ( 1000/madflojo)   Gid: ( 1000/madflojo)
 Access: 2012-05-21 19:28:00.953777255 -0700
 Modify: 2012-05-24 08:30:19.949780228 -0700
 Change: 2012-05-24 08:30:19.949780228 -0700


The stat command shown above displays an inode number of 13862, this is the inode number of my file. It's not often that you need an inode number but to give an example usage if you wanted to compare two files to see if they are a hardlink or not you can check if the inode number is different for each file.


The links count is a count of how many hardlinks exist for that file. The way hardlinks work is basically by creating another access point for the same inode/file. When you have multiple links the number raises. As a note the file shown above does not have any hard links created for it hence why the links count is only 1, the original file is the only link.

Access Time

Access time has been extremely helpful for me in many situations, it answers questions like is it possible to modify the file without the access time changing. As seen in the example, yes. ls is able to show you the access time as well but by default with a -l it will only show you the change time.

I'm sure there are many other cases where stat comes in handy but for me these 3 seem to be the most common. If you know of any more common use cases post a comment and share it with us.

Picture of Benjamin Cane

Benjamin's specialty is keeping the lights on for mission critical systems. He is currently building applications that enable high concurrency financial transactions.

Recently Benjamin published his first book; Red Hat Enterprise Linux Troubleshooting Guide. In addition to writing, he has several Open Source projects focused on making Ops easier. These projects include Automatron, a project enabling auto-healing infrastructure for the masses.


Identify, capture and resolve common issues faced by Red Hat Enterprise Linux administrators using best practices and advanced troubleshooting techniques

What people are saying:
Excellent, excellent resource for practical guidance on how to troubleshoot a wide variety of problems on Red Hat Linux. I particularly enjoyed how the author made sure to provide solid background and practical examples. I have a lot of experience on Red Hat but still came away with some great practical tools to add to my toolkit. - Amazon Review