Tips

Short: Show File Creation, Modification, and Access Times

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.

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.

Show File Creation, Modification, and Access Times:

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.

Closure:

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.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

Meta: The State Of Linux Tips #23

Today's article is just a meta article, an article that I fail to write every…

1 day ago

Is Your Storage Drive An SSD Or An HDD?

Today's article aims to answer a simple question, simply is your storage drive an SSD…

3 days ago

Monitor System Resources With “Resources”

Today is one of those days when I'd like to introduce you to new software…

5 days ago

Short: The Halt Command

Today's article is intentionally short because we're simply going to learn about the basics of…

1 week ago

Installing Flatpaks In Linux

Today we're going to have a pretty easy article where you'll learn about installing Flatpaks…

1 week ago

A Quick Look At The Shutdown Command

This is going to be just a quick article about a command many of you…

2 weeks ago