Linux - Find all files changed in the last 7 days recursively

As a system administrator, it is often necessary to identify files that have been recently modified. This can assist with troubleshooting, monitoring changes, or maintaining security compliance. Fortunately, Linux provides powerful command-line tools to help you quickly locate such files.

The find command is particularly useful for this purpose. To search for files that have been modified within the last 7 days, you can use the following command:

find /path/to/directory -type f -mtime -7 

Here is a breakdown of the command:

  • /path/to/directory: Replace this with the path of the directory you wish to search.
  • -type f: Limits the search to files only (excluding directories).
  • -mtime -7: Finds files that were modified within the last 7 days. The minus sign before the number specifies “less than.”

This command will recursively search the specified directory and list all files that have been modified in the past week. You can adjust the number after -mtime to change the time frame according to your needs.

By regularly monitoring recently changed files, you can stay informed about ongoing activities on your system and respond proactively to any unauthorized or unexpected modifications.

×