Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the stat command. It provides a lot of the same information as ls -l, but in a very different format plus it includes some very useful additional information.
When you use the stat command to display information about a file, you’ll see something like this:
Notice that the command shows us not just the size of the file. It also shows us the size in blocks and the block size (IO Block) and it tells us what kind of file it is (regular file, directory, symlink, etc.). This one’s a regular file. It shows the file permissions both in the rwx fashion and in octal.
The stat command also displays the inode number (808289) and tells us that there is 1 link to this particular file (i.e., the file itself).
The bottom four lines show the date and time that the file was last accessed, last modified, last changed and (sometimes) when it was initially created. Modify represents a change in content while change represents a change in the file’s metadata (e.g., access permissions, file name, etc.). Some systems will include the “birth date”, indicating when the file was originally created.
Most of the information displayed is derived from the file’s inode (the data structure that holds all the metadata). The content, of course, comes from the file while the filename is pulled from the directory.
That’s your Linux tip for today. If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.