How to Find Files Modified in the Last 24 Hours in Ubuntu Linux

The Troubleshooting Time Machine

When you are managing an Ubuntu Linux server, the most common troubleshooting scenario involves trying to figure out what just broke. If a web application was working perfectly yesterday but is throwing database connection errors today, you need to know exactly which configuration files or scripts were modified within that specific timeframe. Manually checking the timestamps on thousands of files across a massive directory structure is impossible. Instead, you can use the terminal to instantly isolate any file that has been touched or altered within the last 24 hours.

Using the find Command with -mtime

The standard Linux find command includes a powerful flag designed specifically for checking modification timestamps: -mtime.

  1. Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
  2. Determine the directory you want to scan. For this example, we will assume you want to scan the /etc/ directory, which holds most system configuration files.
  3. Type the following command:
  4. sudo find /etc/ -type f -mtime -1
  5. Press Enter and provide your administrator password.

How the Command Works

  • sudo gives the command permission to look inside restricted system folders.
  • /etc/ sets the root location for the search.
  • -type f restricts the search strictly to actual files, ignoring directories (which update their modification time simply when a file is added inside them).
  • -mtime -1 is the critical filter. It stands for “Modification Time.” The -1 specifically means “less than 1 day (24 hours) ago.”

Refining the Search Window

You can easily adjust the timeframe to suit your troubleshooting needs. If you want to find files modified in the last two days, change the flag to -mtime -2. Alternatively, if you want to find extremely recent changes, you can use the -mmin flag, which operates in minutes rather than days. For example, to find any file in your web directory modified in the last 60 minutes, you would run: sudo find /var/www/ -type f -mmin -60.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.