I am currently monitoring directories with subdirectories, and I need to detect file rename. what I do is making a md5sum of all files and a keep a file list on another place, and from time to time check again md5sums if files changes are additions or rename.

This process is heavy, I guess there must be a simpler way to just detect rename.

  • What OS are you using?
    – SHawarden
    May 26, 2019 at 21:46
  • linux, ubuntu or debian flavor but the solution may need to works on other distro.
    – dominix
    May 26, 2019 at 21:47
  • You imply three times you only want to detect renames, but once you say "if files changes are additions or rename". Which is it? If it's just renames, then there is no reason to use checksums. Just compare the file names.
    – Sparhawk
    May 26, 2019 at 23:54
  • I never say 'only' ... I need to detect rename in directories where there is files rename and addition.
    – dominix
    May 27, 2019 at 0:27

2 Answers 2


You could try the inotify tools. It is available in a wide selection of Linux-like OSes.

It works by adding a "watch" to a directory, specifying events to listen for. A lovely article on this subject can be found at https://www.linuxjournal.com/content/linux-filesystem-events-inotify

From the manpage:

       The  inotify  API  provides  a mechanism for monitoring file system events.  Inotify can be used to monitor individual files, or to
       monitor directories.  When a directory is monitored, inotify will return events for the directory itself, and for files inside  the
  • 1
    inotify is the way to do this intelligently on Linux. Other Unixes have their own means for asking the kernel to tell you, when something happens, but on Linux that's inotify. There are libraries (like libevent), that allow you to be cross-platform by hiding the OS-specific details under a common API of their own. But anything else -- like polling -- is just wrong.
    – Mikhail T.
    Apr 6 at 20:26

Have you tried aide? I think it will help in your case.

# apt install aide     [On Debian/Ubuntu]
# yum install aide     [On RHEL/CentOS]     
# dnf install aide     [On Fedora 22+]
# zypper install aide      [On openSUSE]
# emerge aide              [On Gentoo]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .