> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Find Files Modified in Last N Minutes in Linux
- URL: https://linuxhandbook.com/find-modified-files/
- Published: 2022-08-17T07:14:43.000Z
- Updated: 2022-11-19T14:03:56.000Z
- Description: Finding recently modified files is a helpful parameter when troubleshooting your code or server. Learn how to find modified files in Linux command line.
- Author: Sagar Sharma
- Tags: Quick Tip

Finding recently modified files is a helpful parameter when troubleshooting your code or server.

What log files were modified? What files changed when I ran this command? The [versatile find command](https://linuxhandbook.com/find-command-examples/) can help you get the answers. 

The command below will find all the files that have been modified in the last five minutes in the current directory.

```
find . -type f -mmin -5
```

That's just one example. Let me share how you can list files that are accessed and created in the last n minutes/days in detail.

## Finding modified files in Linux

Before jumping to the explanatory part, first, I'd like to share the syntax of how you can use the find command to find files that are modified at the last n minute.

```
find [path] -type f -mmin n
```

Here, n indicates how many minutes you want to check for. But you also have some options such as:

- \-n will check for files modified in less than n minutes
- +n will check for files modified in more than n minutes
- n will check for files modified exactly n minutes ago

Similarly, you can also use `-mtime` instead of `-mmin` to check for files modified days ago.

## Finding files modified in the last 5 minutes 

So let's suppose I want to list find files that are just modified in the last 5 minutes in the var directory; my command will be as follows:

```
find .var/ -type f -mmin -5
```

![Find modified files in last 5 minutes](https://linuxhandbook.com/content/images/2022/07/Finding-files-modified-in-last-5-minutes-in-var.png)

Finding modified files in the last 5 minutes

As you can see, it just throws files, and I don't find the given list useful and readable. 

In this case, I'll append `-ls` to have a much cleaner look and more info such as the file owner, permissions, and modification time.

```
find .var/ -type f -mmin -5 -ls
```

![Append ls to get better data on files modified in last n minutes](https://linuxhandbook.com/content/images/2022/07/Finding-files-modified-in-last-5-minutes-in-var-with-ls.png)

Using -ls for better visibility

💡

The find command allows a few actions on its result. The `-ls` is one such action. You don't necessarily need to [use find-exec](https://linuxhandbook.com/find-exec-command/) or [xargs](https://linuxhandbook.com/xargs-command/) for the ls command.

## Finding files modified in the last n days 

To find modified files in the last n days instead of n minutes, you just have to use `-mtime` instead of `-mmin`. 

Suppose I want to find files that have been modified in the last one day, my command would be:

```
find /media/sagar/HDD/Downloads -type f -mtime -1 -ls
```

![Find modified files in last one day](https://linuxhandbook.com/content/images/2022/07/Find-files-modified-in-last-one-day.png)

Finding files modified on the last one day

## Find files older than X days

You can use the `mtime` parameter to find older files that have not been modified recently.

Let's say you want to find files older than 30 days in the current directory. Use this command:

```
find . -mtime +30
```

## Find modified directories in the last n minutes or days 

The find command can also bring a list of modified directories. 

Just change -type f with -type d, which will let you search for directories instead of files. 

For demonstration, I'll be showing how you can get the list of modified directories under /.cache/mozilla/firefox:

```
find .cache/mozilla/firefox/ -type d -mmin -5 -ls
```

![Find modified directories in last n minutes](https://linuxhandbook.com/content/images/2022/07/Finding-directories-modified-in-last-5-minutes-.png)

Listing directories that are modified in the last 5 minutes

Similarly, you can find directories on which you worked a few days ago. 

```
find Downloads/ -type d -mtime -1 -ls
```

![Find modified directory in last n days](https://linuxhandbook.com/content/images/2022/08/Finding-directories-modified-in-last-1-day-.png)

Finding modified directories on the last 1 day

## Finding files that have been recently accessed or created

So how about finding files that were accessed or created last n minutes?

To find files that were accessed in the last n minutes, you'll have to use `-amin` instead of `-mmin`. 

To find files that were accessed in the last 5 minutes inside my preferred directory, I'd be using the given command:

```
find /media/sagar/HDD/Downloads -type f -amin -5 -ls
```

![Find files accessed in last n minutes ](https://linuxhandbook.com/content/images/2022/08/Find-files-accessed-in-last-5-minutes.png)

Find files accessed in the last 5 minutes

In the same way, you can also find files created in the last n minutes by using `-cmin` instead of `-amin`.

```
find /media/sagar/HDD/Downloads -type f -cmin -5 -ls
```

![Find files created in last n minutes](https://linuxhandbook.com/content/images/2022/08/Find-files-created-in-last-5-minutes.png)

Finding files created in the last 5 minutes

## Conclusion

Basically, there is no limit to the use cases. You can modify it from -n to +n and you can search for older files. Use the `ctime` and you can get recently created or ancient files.

Another common example is [finding files by their name](https://linuxhandbook.com/find-files-by-name/).

[Find Files by Name in Linux \[5 Frequent Use Cases\]Finding files by their name is one of the most common scenarios of finding files in Linux. Here are a few examples to help.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookTeam LHB![](https://linuxhandbook.com/content/images/2022/09/find-files.png)](https://linuxhandbook.com/find-files-by-name/)

Learning the basics allows you to use the find command as per your need. I believe this tutorial gave you enough understanding of using the time parameter of the find command.