Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use drag and drop to copy and move files. One disadvantage of that is files might end up to the wrong places. So, let's say I copied/moved many files and folders to multiple different destinations.

How can I track down where everything ended up to make sure that everything was copied/moved to the right places?

share|improve this question
But 'Undo' doesn't say where the files were copied to? – Amr Ibrahim Jan 28 '14 at 9:49
up vote 2 down vote accepted

What you are asking for is a "file system watcher".

iWatch Install iWatch

iWatch is a realtime filesystem monitoring program. It's a simple perl script to monitor changes in specific directories/files and send email notification immediately. It reads the dir/file list from xml config file and needs inotify support in kernel (Linux Kernel >= 2.6.13).

There are more but this seems the most simple method, is native to Ubuntu and uses inotify (so it does not hog the system).

iWatch comes in 2 methods:

  1. command line
  2. daemon

Some command line options for logging:

-m <email address>
   Specify the contact point's email address. Without this option, iwatch will 
   not send any email notification. 

-s <on|off>
   Enable or disable reports to the syslog (default is off/disabled)

Some command line examples:

iwatch /tmp

monitor changes in /tmp directory with default events

iwatch -r -e access,create -m cahya@localhost -x /etc/mail /etc

monitor only access and create events in /etc directory recursively with /etc/mail as exception and send email notification to cahya@localhost.

iwatch -r -c "(w;ps -ef)|mail -s '%f was changed' cahya@localhost" /bin

monitor /bin directory recursively and execute the command.

iwatch -r -X '\.svn' ~/projects

monitor ~/projects directory recursively, but exclude any .svn directories inside. This can't be done with a normal '-x' option since '-x' can only exclude the defined path.

Example config file when using daemon mode mode. Logging is done with XML options in the configuration file:

  <guard email="myadmin@localhost" name="IWatch"></guard>
  <title>Public Website</title>
  <contactpoint email="webmaster@localhost" name="Web Master"/>
    <path type="single">/var/www/localhost/htdocs</path>
    <path type="single" syslog="on">/var/www/localhost/htdocs/About</path>
    <path type="recursive">/var/www/localhost/htdocs/Photos</path>
  <title>Operating System</title>
  <contactpoint email="admin@localhost" name="Administrator"/>
    <path type="recursive">/etc/apache2</path>
    <path type="single">/etc/passwd</path>
    <path type="recursive">/etc/mail</path>
    <path type="exception">/etc/mail/statistics</path>
    <path type="single" filter="shadow|passwd">/etc</path>
  <title>Only Test</title>
  <contactpoint email="root@localhost" name="Administrator"/>
    <path type="single" alert="off" exec="(w;ps -ef)|mail -s %f
    <path type="single" events="access,close" alert="off" exec="(w;ps -ef)|mail -s %f
    <path type="single" events="default,access" alert="off" exec="(w;ps -ef)|mail -s '%f is
      accessed' root@localhost">/tmp/dir3</path>
    <path type="single" events="all_events" alert="off">/tmp/dir4</path>

With this configuration, iwatch will monitor a single directory /var/www/localhost/htdocs without its sub directories, and any notification will be sent to the contact point webmaster@localhost. But it will monitor the whole directory tree of /etc/apache2, including any sub directories created later after the IWatch is started. You can use also create exceptions here if you don't want to get notification for a file or subdirectory inside the monitored directory.

share|improve this answer
OK, I did 'iwatch -d -v' in a terminal, then copied some files from a USB stick to a folder. Where can I find the recorded log? – Amr Ibrahim Jan 28 '14 at 10:16
If you used command line: where did you tell it to log too? – Rinzwind Jan 28 '14 at 10:27
Now I understand, I have to make a config file first to use the daemon mode, or use the command line mode. – Amr Ibrahim Jan 28 '14 at 10:51
Yes and it is "or". Can not use both at the same time ;) Command line has an '-e' option that executes a command (how this is usefull not sure yet but I am guesssing it could also be used to copy the results to a file instead of just mailing or using syslog) – Rinzwind Jan 28 '14 at 10:55
Do I have to run iwatch as sudo to enable it to write to syslog? – Amr Ibrahim Jan 30 '14 at 17:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.