find recently modified files in linux

How to Find Recently Modified Files in Linux

Sometimes you may need to find recently modified files in Linux. You can easily do this with ‘find’ command. In this article, we will look at how to search for recently modified files, along with several use cases for the same.


How to Find Recently Modified Files in Linux

You can easily look for recently modified files & directories in Linux using find command. It allows you to find files with different search criteria. For our purpose, we will use -mtime or -mmin options.

-mtime allows you to look for files that have been modified exactly n days ago while -mmin option allows you to search files & directories that have been modified at least n minutes ago.


Find Files modified 10 days ago

Here is the command to find files & directories modified within the last 10 days. Replace /home below with your directory of choice. You need to specify number of days after -mtime option. A negative number indicates less than n days, while positive number searches for files modified more than n days ago.

$ sudo find /home -mtime -10

Here is the find command to look for files & directories more than 10 days ago. In this case, we specify +10 instead of -10 for mtime.

$ sudo find /home -mtime +10

If you only want to find files and not directories then use -type f option in all the above and following commands.

$ sudo find /home -type f -mtime +10


Find Files modified today

Find also supports an option -newermt that allows you to filter files & directories based on specified date.

-newermt 'yyyy-mm-dd'

Here is the command to list files & directories modified today. Replace the date below with your date of choice. If you enter today’s date, find command will list all files & directories modified today.

$ sudo find /home -newermt '2021-06-21'

Here is another command to do the same thing.

$ sudo find /home -newermt "-24 hours"

You may also use mtime option for the same.

$ sudo find /home -mtime -1


Find Files modified in last hour

Here is the command to list files & directories modified in the last hour.

$ sudo find /home -newermt "-1 hours"

You can also use mmin option to do the same thing. Here you need to specify number of minutes after mmin option. -ve sign indicates less than n minutes while +ve sign indicates more than n minutes.

$ sudo find /home -mmin 60


Find Files modified in last 5 minutes

Here is the command to list files & directories modified in last 5 minutes. Replace 5 with your choice of minutes.

$ sudo find /home -newermt "-5 minutes"

You can also use mmin option to do the same thing.

$ sudo find /home -mmin -5

That’s it. We have looked at how to find files & directories recently modified in Linux, with a bunch of common use cases.

Also read:

How to Install VNC Server in Ubuntu
How to Redirect Wildcard Subdomains to Root Domain
How to Mount ISO Files in Ubuntu
How to Mount Drive from Terminal
How to Disable mod_deflate in Apache Server

Leave a Reply

Your email address will not be published. Required fields are marked *