Stat: Detailed information about a file

Written by Benjamin Cane on 2012-05-24 15:46:31 | 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.

comments powered by Disqus
Picture of Benjamin Cane

Benjamin is a Systems Architect working in the financial services industry focused on platforms that require Continuous Availability. He has been working with Linux and Unix for over 10 years now and has recently published his first book; Red Hat Enterprise Linux Troubleshooting Guide.


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

What people are saying:
Red Hat Enterprise Linux Troubleshooting Guide may just be all you need in your quest to wear the red hat. - Perry N.
Buy on Amazon

Sponsored by