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:

The outcome should match:

You can check the man page with this command:

Doing so will show you that stat is described like:

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:

Now, pick a file…

When you’ve picked a file, use the stat command. The syntax is easy:

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:

Here’s an example output:

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:

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.

How To: Find Out When A File Was Created

Today, we’re going to learn how to find out when a file was created. Odds are good that you could use the right click menu in a GUI file manager and figure it out, or you can sort by time and show details, that sort of stuff. Those being ‘easy’ we’ll learn how to find out when a file was created in the terminal.

Yeah, a lot of these articles explain how to do things in a terminal – even when there’s a nice graphical way to accomplish those same things. While it’s true that we may have different shells, we’re far more universal in the terminal than we are in a graphical desktop environment.

It’s good to learn how to do things in the terminal. If you can accomplish your goal in the terminal – you can accomplish it quickly and easily everywhere. That’s a pretty great benefit. (It’s not even unique to Linux – as you can do a whole lot via command line in Windows and MacOS.)

Also, today’s article feels a bit like work. I was hoping that it’d take longer to really start feeling that way. It’s okay. I picked a brief subject, what should be a short article, and that’ll be almost like a day off.

Find Out When A File Was Created:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

With your terminal open, change to the directory that contains the file you want to find out when it was created. Let’s say it’s in your Documents directory:

Now, you can just use the -l flag with the ls command. That’d look like this –  showing the creation date (and maybe time, if the file is recent enough) for all the files in that directory:

That’s pretty messy, especially if you have a lot of files in the directory. So, you can specify the file for which you want to find the creation date by specifying the filename in the command itself, like so:

That’ll do it for you. Well, it should do it for you! If not, something’s broken and don’t ask me to fix it!

Closure:

There you have it… You can now tell when a file was created. It’s not a very difficult process and it’s one you can easily commit to memory. I find myself using it when I’ve created a file and then can’t find it among other files with similar names – I’ll check to wee when a file was created and figure it out that way.

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 own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.