Today’s article is short because there’s no reason to make it longer and we’ll just show file creation, modification, and access times. This is just a simple process and won’t take all that much to learn. It shouldn’t take too long to explain.
Files contain metadata. This can be everything from the GPS location of an image file to the kind of camera used. You can even add your metadata fields with audio files, for example.
For example, we’ve previously covered metadata in these articles:
How To: Sanitize Exif Data From Your Digital Images For Privacy Sake
Review: MetaClean (Clean Exif/meta Data From Email Attachments Automatically)
Well, your files contain other metadata. This information includes things like file creation, modification, and access times. You can easily find out when a file was created. It’s easy to show when the file was modified and just as easy to see when the file was last accessed.
Nice and simple, right?
Well, we’ll be using the stat command.
You won’t need to install anything. You’ll find that the stat application is already available. You can verify this with:
which stat
The outcome should match:
$ which stat /usr/bin/stat
You can check the man page with this command:
man stat
Doing so will show you that stat is described like:
stat - display file or file system status
Which is exactly what we need to show creation, modification, and access times. This will be the correct tool for the job.
This is a terminal-based process and you can usually access your default terminal by pressing CTRL + ALT + T. If that doesn’t work, find the terminal in your application menu.
With your terminal open, list the files:
ls -la
Now, pick a file…
When you’ve picked a file, use the stat command. The syntax is easy:
stat <file_name>
When you opened your default terminal, you probably opened it in your home directory. Most of you will have a ~/.bashrc file, so we’ll use that. An example of this stat command would be:
stat ~/.bashrc
Here’s an example output:
$ stat ~/.bashrc File: /home/kgiii/.bashrc Size: 3831 Blocks: 8 IO Block: 4096 regular file Device: 802h/2050d Inode: 6815747 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ kgiii) Gid: ( 1000/ kgiii) Access: 2024-03-06 15:04:01.821753362 -0500 Modify: 2024-02-15 22:01:20.734612826 -0500 Change: 2024-02-15 22:01:20.734612826 -0500 Birth: 2023-11-26 01:48:18.886257694 -0500
As you can see, there’s the ‘birth’ (file creation time), an access time, and a changed time. There’s a lot of other information, but that’s outside the scope of this article.
Be sure to read the man page:
man stat
You can use several flags to extract just the information you want. If you wanted to, this would be useful for scripting or other programming. You don’t have to have the full output. For this simple and short article, the information isn’t that overwhelming. I see no reason to cover any particular flags unless I intended to cover a half dozen of them. You can find those just fine on your own.
This has just been a short article. I wanted to cover the stat command and there’s not much to it – for the average user. File management is a pretty advanced topic and we cover that often. This time around, it’s just file creation, modification, and access times. Nothing too advanced.
I don’t do many of these short articles. I probably should, as they’re quick and get straight to the point. They’re quick articles that should be plenty easy to process and you don’t have to wade through a lot of text to get to the point of the article. If you like them, let me know.
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.
Today we'll cover one way to enable or disable your network interface in the Linux…
Today's exercise is a nice and simple exercise where we check your NIC speed in…
Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…
I think I've covered this before with the ls command but this time we'll count…
Today we'll be learning about a basic Linux command that's known as 'uname' and it…
If you've used hardinfo in the past, it may interest you to know that hardinfo…