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

The Post-Breach Audit

If you suspect an attacker has successfully breached your Ubuntu Linux server, time is of the essence. You cannot manually hunt through thousands of directories looking for malicious scripts or tampered configuration files. You must instantly isolate the exact files that the attacker created or modified during the timeframe of the breach. To do this, you must instruct the Linux filesystem to search exclusively by modification timestamp rather than by filename or size.

Using the find Command with -mtime

The Linux find command utilizes the -mtime (modification time) flag to filter files strictly based on the exact day their content was last changed.

  1. Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
  2. To search the entire /var/www/html/ web directory for every single file that has been modified within the last 24 hours, type the following command exactly:
    sudo find /var/www/html/ -type f -mtime -1
  3. Press Enter and provide your administrator password.

Understanding Time Intervals

The number following the -mtime flag represents blocks of 24 hours. The minus sign (-1) is critical: it tells the search engine to find files modified less than 24 hours ago. If you want to find files modified exactly 3 days ago, you would use -mtime 3. If you are conducting a massive audit and need to see all files modified at any point within the last 7 days, you would use -mtime -7, instantly outputting a comprehensive timeline of all recent server activity.

Get the best tech tips delivered straight to your inbox.

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