How to Find Recently Modified Files/Folders in Linux

If you are using the Linux system for daily operation, your home directory files will increase dramatically over time.

If you want to find a directory size in Linux, check out the following article

If you have thousands of files, you can’t remember the file name you recently changed.

Also, if you want to check the list of files created or modified or accessed for any purpose.

This article will help you to meet your need.

How does it work, and on what basis do we decide?

In Linux, each file contains three timestamps that are updated when the file is modified or replaced.

A file in Linux contains three timestamps:

  • atime: access time or Last access time
  • mtime: modify time or Last modification time
  • ctime: change time or Last change time

If you want to know more about this, read the explanation below.

  • atime/amin: The last time the file was accessed by some command or application.
  • mtime/mmin: The last time the file’s contents was modified.
  • ctime/cmin: The last time the file’s attribute was modified.

How do we check all timestamps of a file?

It can be easily saw with stat command. It show you all the timestamps of a file.

The common syntax is as follows:

stat [File_Name]
# stat /home/daygeek/shell-script/remote-backup.sh

  File: /home/daygeek/shell-script/remote-backup.sh
  Size: 436       	Blocks: 8          IO Block: 4096   regular file
Device: 10301h/66305d	Inode: 2490772     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/ daygeek)   Gid: ( 1000/ daygeek)
Access: 2019-09-08 01:00:20.963127924 +0530
Modify: 2019-09-08 01:04:56.274279514 +0530
Change: 2019-09-08 01:04:56.274279514 +0530
 Birth: 2019-09-08 01:00:20.963127924 +0530

How to use numerical arguments in this example. If you use “-mtime n”. This returns a list of files that was last modified 24 hours ago.

  • +n: for greater than n
  • -n: for less than n
  • n: for exactly n

See the format below for a better understanding.

  • -mtime +10: Use this format, if you want to find a file that was modified 10 days ago.
  • -mtime -10: Use this format, if you want to find a file that was modified less than 10 days.
  • -mtime 10: Use this format, if you want to find a file that was modified exactly 10 days ago.

1) How to Sort Files and Folders in Reverse Order Based on its Conversion Time

This can be achieved simply by using the ls command.

It sorts files and folders in reverse order based on conversion time.

# ls -ltrh /home/daygeek/shell-script

total 312K
-rw-r--r-- 1 daygeek daygeek  616 Jun  2 13:25 cpu-alert2.sh
-rw-r--r-- 1 daygeek daygeek  830 Jun 14 11:54 process.sh
-rw-r--r-- 1 daygeek daygeek  776 Jun 14 12:00 memory-monitor.sh
-rw-r--r-- 1 daygeek daygeek  157 Jul 29 18:29 service1.sh
-rw-r--r-- 1 daygeek daygeek  361 Jul 29 19:45 service3a.sh
-rw-r--r-- 1 daygeek daygeek  296 Aug  4 01:27 servicem.sh
drw-r--r-- 3 daygeek daygeek 4.0K Aug 19 12:33 backup
-rwxr-xr-x 1 daygeek daygeek   73 Aug 23 12:51 guna_server.sh
-rw-r--r-- 1 daygeek daygeek  436 Sep  8 01:04 remote-backup.sh
-rw-r--r-- 1 daygeek daygeek  367 Sep  8 01:19 remote-backup-2.sh
-rw-r--r-- 1 daygeek daygeek  418 Sep  8 03:54 remote-backup-1.sh
-rw-r--r-- 1 daygeek daygeek  459 Sep  8 04:21 list-remote-backup.sh
drwxr-xr-x 2 daygeek daygeek 4.0K Sep 20 12:53 test
drwxr-xr-x 2 daygeek daygeek 4.0K Sep 20 12:54 test1
drwxr-xr-x 2 daygeek daygeek 4.0K Sep 20 12:54 test3

2) How to Sort Only Folders in Reverse Order Based on File Conversion Time

If you want to sort only folders in reverse order based on the conversion time, use the below command.

# ls -ltrh /home/daygeek/shell-script | grep ^d

drw-r--r-- 3 daygeek daygeek 4.0K Aug 19 12:33 backup
drwxr-xr-x 2 daygeek daygeek 4.0K Sep 20 12:53 test
drwxr-xr-x 2 daygeek daygeek 4.0K Sep 20 12:54 test1
drwxr-xr-x 2 daygeek daygeek 4.0K Sep 20 12:54 test3

3) How to Find Only Files That were Modified 120 Days Ago

The below find command will show a list of files that were changed 120 days ago.

# find /home/daygeek/shell-script -type f -mtime +120 -ls

  2491042      4 -rw-r--r--   1  daygeek  daygeek       410 Apr 27 23:58 /home/daygeek/shell-script/disk-space-alert.sh
  1705245      4 -rwxr-xr-x   1  daygeek  daygeek        41 Jan 15  2019 /home/daygeek/shell-script/ovh.sh
  1704244      4 -rw-r--r--   1  daygeek  daygeek        99 Jan 19  2019 /home/daygeek/shell-script/file-copy.sh
  1744131      4 -rwxr-xr-x   1  daygeek  daygeek      1361 Feb  9  2019 /home/daygeek/shell-script/cpu-mem-check.sh
  1719630      4 -rwxr-xr-x   1  daygeek  daygeek        82 Mar  1  2019 /home/daygeek/shell-script/pass-gen.sh
  1719891      4 -rwxr-xr-x   1  daygeek  daygeek       274 Mar 16  2019 /home/daygeek/shell-script/pass-multi-user.sh
  2490973      4 -rwxr-xr-x   1  daygeek  daygeek       237 Apr  6 10:40 /home/daygeek/shell-script/mysql_backup_1.sh
  2490935      0 -rw-r--r--   1  daygeek  daygeek         0 Apr 29 10:25 /home/daygeek/shell-script/test.txt
  1736513      4 -rw-r--r--   1  daygeek  daygeek       227 Mar 17  2019 /home/daygeek/shell-script/server-list.txt
  2490942      8 -rw-r--r--   1  daygeek  daygeek      4780 Apr 11 14:57 /home/daygeek/shell-script/2g.out
  1738172      4 -rwxr-xr-x   1  daygeek  daygeek       214 Mar 10  2019 /home/daygeek/shell-script/user-add.sh
  1719571      4 -rwxr-xr-x   1  daygeek  daygeek       151 Mar 16  2019 /home/daygeek/shell-script/pass-up.sh
  2491095    140 -rwxr-xr-x   1  daygeek  daygeek    139406 May 12 20:26 /home/daygeek/shell-script/xsos
  1720392      4 -rwxr-xr-x   1  daygeek  daygeek        76 Mar 17  2019 /home/daygeek/shell-script/port_scan.sh
  1730638      4 -rwxr-xr-x   1  daygeek  daygeek        98 Jan 11  2019 /home/daygeek/shell-script/passwd-up1.sh
  2490982      4 -rwxr-xr-x   1  daygeek  daygeek       241 Apr  6 10:49 /home/daygeek/shell-script/mysql_backup_2.sh
  2490955      4 -rwxr-xr-x   1  daygeek  daygeek       761 Apr  6 21:36 /home/daygeek/shell-script/mysql_backup.sh
  1717834      4 -rwxr-xr-x   1  daygeek  daygeek       159 Jan 11  2019 /home/daygeek/shell-script/passwd-up.sh
  2491025      4 -rw-r--r--   1  daygeek  daygeek        78 Apr 26 11:39 /home/daygeek/shell-script/bulk-package-install.sh

4) How to Find Only Files That was Modified Less Than 15 Days

The below find command will show a list of files that have changed within 15 days.

# find /home/daygeek/shell-script -type f -mtime -15 -ls

  2490782      4 -rw-r--r--   1  daygeek  daygeek       418 Sep  8 03:54 /home/daygeek/shell-script/remote-backup-1.sh
  2494508      4 -rw-r--r--   1  daygeek  daygeek       436 Sep 20 12:54 /home/daygeek/shell-script/test3/remote-backup.sh
  2490783      4 -rw-r--r--   1  daygeek  daygeek       538 Sep 20 12:53 /home/daygeek/shell-script/test/cpu-alert.sh
  2490772      4 -rw-r--r--   1  daygeek  daygeek       436 Sep  8 01:04 /home/daygeek/shell-script/remote-backup.sh
  2494505      4 -rw-r--r--   1  daygeek  daygeek       776 Sep 20 12:54 /home/daygeek/shell-script/test1/memory-monitor.sh
  2490786      4 -rw-r--r--   1  daygeek  daygeek       367 Sep  8 01:19 /home/daygeek/shell-script/remote-backup-2.sh
  2490789      4 -rw-r--r--   1  daygeek  daygeek       459 Sep  8 04:21 /home/daygeek/shell-script/list-remote-backup.sh

5) How to Find Only Files That were Modified Exactly 10 Days Ago

The below find command will show you a list of files that were changed exactly 10 days ago.

# find /home/daygeek/shell-script -type f -mtime 10 -ls

  2490782      4 -rw-r--r--   1  daygeek  daygeek       418 Sep  8 03:54 /home/daygeek/shell-script/remote-backup-1.sh
  2490772      4 -rw-r--r--   1  daygeek  daygeek       436 Sep  8 01:04 /home/daygeek/shell-script/remote-backup.sh
  2490786      4 -rw-r--r--   1  daygeek  daygeek       367 Sep  8 01:19 /home/daygeek/shell-script/remote-backup-2.sh
  2490789      4 -rw-r--r--   1  daygeek  daygeek       459 Sep  8 04:21 /home/daygeek/shell-script/list-remote-backup.sh

6) How to Find Only Files That Was Modified Less Than 30 Mins

The below find command will show a list of files that have changed within 30 mins.

# find /home/daygeek/ -type d -mmin -30 -ls

  6553934      4 drwx------   2  daygeek  daygeek      4096 Sep 20 14:08 /home/daygeek/.cache/google-chrome/Default/Cache/index-dir
  1974320      4 drwxr-xr-x   3  daygeek  daygeek      4096 Sep 20 14:06 /home/daygeek/.config/Notepadqq/backupCache
  1974321      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 14:06 /home/daygeek/.config/Notepadqq/backupCache/window_94904345125616
  6553884      4 drwx------  19  daygeek  daygeek      4096 Sep 20 14:03 /home/daygeek/.config/google-chrome
  6553899      4 drwx------  26  daygeek  daygeek      4096 Sep 20 14:07 /home/daygeek/.config/google-chrome/Default
  6553923      4 drwx------   2  daygeek  daygeek      4096 Sep 20 13:50 /home/daygeek/.config/google-chrome/Default/Sync\ Data/LevelDB
  6823938      4 drwx------   2  daygeek  daygeek      4096 Sep 20 14:03 /home/daygeek/.config/google-chrome/Default/databases/https_translate.google.co.in_0
  6553915      4 drwx------   2  daygeek  daygeek      4096 Sep 20 13:54 /home/daygeek/.config/google-chrome/Safe\ Browsing
  1704068      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 14:05 /home/daygeek/.local/share/tracker/data
  1704089      4 drwx------   2  daygeek  daygeek      4096 Sep 20 14:04 /home/daygeek/.local/share/gvfs-metadata
  1703995      4 drwx------   3  daygeek  daygeek      4096 Sep 20 14:05 /home/daygeek/.local/share/gnome-shell

7) How to Find Modified Folder in Less Than 5 Days

This command displays only folders modified within 5 days.

# find /home/daygeek/shell-script -type d -mtime -5 -ls

  2494645      4 drwxr-xr-x   6  daygeek  daygeek      4096 Sep 20 12:55 /home/daygeek/shell-script
  2498566      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 12:54 /home/daygeek/shell-script/test3
  2498564      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 12:53 /home/daygeek/shell-script/test
  2498565      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 12:54 /home/daygeek/shell-script/test1

8) How to Find Files and Folders That Was Modified in Less Than 15 Days

This command displays a list of files and folders modified within 15 days.

# find /home/daygeek/shell-script -mtime -15 -ls

  2494645      4 drwxr-xr-x   6  daygeek  daygeek      4096 Sep 20 12:55 /home/daygeek/shell-script
  2490782      4 -rw-r--r--   1  daygeek  daygeek       418 Sep  8 03:54 /home/daygeek/shell-script/remote-backup-1.sh
  2498566      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 12:54 /home/daygeek/shell-script/test3
  2494508      4 -rw-r--r--   1  daygeek  daygeek       436 Sep 20 12:54 /home/daygeek/shell-script/test3/remote-backup.sh
  2498564      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 12:53 /home/daygeek/shell-script/test
  2490783      4 -rw-r--r--   1  daygeek  daygeek       538 Sep 20 12:53 /home/daygeek/shell-script/test/cpu-alert.sh
  2490772      4 -rw-r--r--   1  daygeek  daygeek       436 Sep  8 01:04 /home/daygeek/shell-script/remote-backup.sh
  2498565      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 12:54 /home/daygeek/shell-script/test1
  2494505      4 -rw-r--r--   1  daygeek  daygeek       776 Sep 20 12:54 /home/daygeek/shell-script/test1/memory-monitor.sh
  2490786      4 -rw-r--r--   1  daygeek  daygeek       367 Sep  8 01:19 /home/daygeek/shell-script/remote-backup-2.sh
  2490789      4 -rw-r--r--   1  daygeek  daygeek       459 Sep  8 04:21 /home/daygeek/shell-script/list-remote-backup.sh

9) How to Find Modified Files and Folders Starting from a Given Date to the Latest Date

This command allows you to find a list of files and folders that have been modified starting from a given date to the latest date.

# find /home/daygeek/shell-script -newermt "2019-09-08" -ls

  2494645      4 drwxr-xr-x   6  daygeek  daygeek      4096 Sep 20 12:55 /home/daygeek/shell-script
  2490782      4 -rw-r--r--   1  daygeek  daygeek       418 Sep  8 03:54 /home/daygeek/shell-script/remote-backup-1.sh
  2498566      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 12:54 /home/daygeek/shell-script/test3
  2494508      4 -rw-r--r--   1  daygeek  daygeek       436 Sep 20 12:54 /home/daygeek/shell-script/test3/remote-backup.sh
  2498564      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 12:53 /home/daygeek/shell-script/test
  2490783      4 -rw-r--r--   1  daygeek  daygeek       538 Sep 20 12:53 /home/daygeek/shell-script/test/cpu-alert.sh
  2490772      4 -rw-r--r--   1  daygeek  daygeek       436 Sep  8 01:04 /home/daygeek/shell-script/remote-backup.sh
  2498565      4 drwxr-xr-x   2  daygeek  daygeek      4096 Sep 20 12:54 /home/daygeek/shell-script/test1
  2494505      4 -rw-r--r--   1  daygeek  daygeek       776 Sep 20 12:54 /home/daygeek/shell-script/test1/memory-monitor.sh
  2490786      4 -rw-r--r--   1  daygeek  daygeek       367 Sep  8 01:19 /home/daygeek/shell-script/remote-backup-2.sh
  2490789      4 -rw-r--r--   1  daygeek  daygeek       459 Sep  8 04:21 /home/daygeek/shell-script/list-remote-backup.sh

10) How to Find All Files and Folders Modified in The Last 24 Hours

Alternatively, you can use an easy-to-understand format like the one below to find files and folders that have been changed over the past 24 hours.

# find /home/daygeek -newermt "1 day ago" -ls
or
# find /home/daygeek -newermt "-24 hours" -ls
or
# find /home/daygeek -newermt "yesterday" -ls

  1704781     36 -rw-------   1  daygeek  daygeek     35943 Sep 20 12:13 /home/daygeek/.local/share/keyrings/login.keyring
  1705911      8 -rw-r--r--   1  daygeek  daygeek      4548 Sep 20 12:15 /home/daygeek/Remove-Symbolic-Links-in-Linux.txt
  1703977     56 drwxr-xr-x  14  daygeek  daygeek     53248 Sep 20 08:04 /home/daygeek/Downloads
  1707507     36 -rw-r--r--   1  daygeek  daygeek     36092 Sep 20 08:04 /home/daygeek/Downloads/picture-networking-9.png
  2490860     20 drwxr-xr-x   4  daygeek  daygeek     20480 Sep 20 08:18 /home/daygeek/Desktop/Daily_Activity/2g-images/Designed_Image
  2490796     72 -rw-r--r--   1  daygeek  daygeek     71000 Sep 20 08:18 /home/daygeek/Desktop/Daily_Activity/2g-images/Designed_Image/how-to-remove-delete-symbolic-links-in-linux-1.png
  1966609    188 -rw-r--r--   1  daygeek  daygeek    192110 Sep 20 12:39 /home/daygeek/Desktop/Daily_Activity/magi.txt
  1709893     36 -rw-r--r--   1  daygeek  daygeek     34631 Sep 20 07:36 /home/daygeek/old-Mysqladmin-command.txt
  1710619     40 drwxr-xr-x   2  daygeek  daygeek     36864 Sep 20 12:35 /home/daygeek/Pictures/BingWallpaper
  1710658    340 -rw-r--r--   1  daygeek  daygeek    348014 Sep 20 12:35 /home/daygeek/Pictures/BingWallpaper/20190920-th?id=OHR.ThePando_EN-US1263045290_1920x1080.jpg

11) How to Find a List of “sh” Extension Files Accessed in the Last 30 Days

This command helps you to find a list of files with “sh” extension accessed in the last 30 days.

# find /home/daygeek/shell-script  -type f -iname "*.sh" -atime -30 -ls

  2490782      4 -rw-r--r--   1  daygeek  daygeek       418 Sep  8 03:54 /home/daygeek/shell-script/remote-backup-1.sh
  2494508      4 -rw-r--r--   1  daygeek  daygeek       436 Sep 20 12:54 /home/daygeek/shell-script/test3/remote-backup.sh
  2490783      4 -rw-r--r--   1  daygeek  daygeek       538 Sep 20 12:53 /home/daygeek/shell-script/test/cpu-alert.sh
  2490772      4 -rw-r--r--   1  daygeek  daygeek       436 Sep  8 01:04 /home/daygeek/shell-script/remote-backup.sh
  2494505      4 -rw-r--r--   1  daygeek  daygeek       776 Sep 20 12:54 /home/daygeek/shell-script/test1/memory-monitor.sh
  2490786      4 -rw-r--r--   1  daygeek  daygeek       367 Sep  8 01:19 /home/daygeek/shell-script/remote-backup-2.sh
  2490789      4 -rw-r--r--   1  daygeek  daygeek       459 Sep  8 04:21 /home/daygeek/shell-script/list-remote-backup.sh

12) How to Find Files That Have Been Modified Over a Period of Time

The below command shows a list of files that have changed in the last 20 minutes.

# find /home/daygeek -cmin -20 -ls

  6595804  11440 -rw-r--r--   1  daygeek  daygeek  11713819 Sep 20 13:24 /home/daygeek/.config/google-chrome/Safe\ Browsing/UrlSoceng.store
  6586612     12 -rw-r--r--   1  daygeek  daygeek     11171 Sep 20 13:24 /home/daygeek/.config/google-chrome/Safe\ Browsing/UrlSuspiciousSite.store
  6595504    216 -rw-r--r--   1  daygeek  daygeek    219195 Sep 20 13:24 /home/daygeek/.config/google-chrome/Safe\ Browsing/UrlUws.store
  6553893     28 -rw-------   1  daygeek  daygeek    270336 Sep 20 13:32 /home/daygeek/.config/google-chrome/ShaderCache/GPUCache/data_1
  6595827     88 -rw-------   1  daygeek  daygeek     87328 Sep 20 13:20 /home/daygeek/.config/google-chrome/Local\ State
  2490785    104 -rw-r--r--   1  daygeek  daygeek    105595 Sep 20 13:30 /home/daygeek/.local/share/fish/fish_history
  1703995      4 drwx------   3  daygeek  daygeek      4096 Sep 20 13:33 /home/daygeek/.local/share/gnome-shell
  1704389      4 -rw-r--r--   1  daygeek  daygeek      1258 Sep 20 13:33 /home/daygeek/.local/share/gnome-shell/application_state
  1707425     16 -rw-------   1  daygeek  daygeek     14108 Sep 18 12:52 /home/daygeek/.bash_history

13) How to Find a List of Files Created Today

This command enables you to find a list of files created today.

# find /home/daygeek/shell-script -type f -ctime -1 -ls

2494508      4 -rw-r--r--   1  daygeek  daygeek       436 Sep 20 12:54 /home/daygeek/shell-script/test3/remote-backup.sh
2490783      4 -rw-r--r--   1  daygeek  daygeek       538 Sep 20 12:53 /home/daygeek/shell-script/test/cpu-alert.sh
2494505      4 -rw-r--r--   1  daygeek  daygeek       776 Sep 20 12:54 /home/daygeek/shell-script/test1/memory-monitor.sh

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...