Skip to main content
Quick Tip

Find mtime of File in Linux

See when was the file last modified with mtime in Linux.

Sagar Sharma

The mtime is a timestamp in Linux that tells you when the file was modified last time.

There are two ways you can find the mtime in Linux: You can either use commands that give you mtime by default or use the mtime flag.

In this tutorial, I will walk you through 3 ways you can find mtime in Linux:

  1. Using the stat command (easy)
  2. Using the ls command

I'll also discuss using the find command with the mtime flag.

Find mtime using the stat command

The stat command in Linux is used to get detailed information about the filesystem or file in Linux.

But the best part is it shows the mtime along with the ctime and atime by default without any additional flags so all you have to do is append the filename to the stat command as shown:

stat Filename
Use the stat command to get the mtime in Linux

To learn more about the mtime, ctime and atime timestaps, refer to our detailed guide on timestamps in Linux:

File Timestamps in Linux: atime, mtime, ctime Explained
Let’s see what are the various kinds of file timestamps in Linux, how to see the timestamps for a file and how to change the timestamps.

Find mtime using the ls command

When you use the ls command with the -l flag to get the list view, it also shows the mtime of the file.

The best part of using the ls command for this purpose is you can use a directory as a target and list down mtime of multiple files at once.

To use the ls command to find the mtime, all you have to do is use the following command syntax:

ls -l filename/directory
Get the mtime in Linux using the ls command

Additional Tip: Find files based on mtime with find command

While the find command may look super complex to use (cough regex cough), once you get used to it, there's no going back.

But this time, you are required to use the -mtime flag with the find command, and being one of the most powerful commands of Linux, it is obvious that you get multiple options there.

To find files that were modified exactly n days ago:

find /path/to/search -mtime n

To find files that were modified less than n days ago:

find /path/to/search -mtime -n

To find files that were modified more than n days ago:

find /path/to/search -mtime +n

So let's say I want to list down files inside the /usr directory which was modified 5 days ago, then I will be using the following command:

find /usr -mtime 5

If you are interested, you can check our detailed guide explaining how to find directories that were modified N days ago:

Find Files Modified in Last N Minutes in Linux
Finding recently modified files is a helpful parameter when troubleshooting your code or server. Learn how to find modified files in Linux command line.

Wrapping Up...

This was a quick tutorial on how you can find the modified time (mtime) in Linux in 3 different ways.

I've tried to keep this short and helpful so you can get the most out of it in the least time possible. I hope you will find this helpful and less time-consuming.

If you have questions or want to suggest what should be covered next, then leave a comment.

Sagar Sharma