Score:2

Do we have a tool that can track file level changes at a user level for a directory?

vn flag

Do we have a tool that can track file level changes at a user level for a directory?

To further add,

My requirement is this -

This is the directory i would like to track /var/lib/docker/volumes/shared/_data -

Any changes to any files inside this folder should be tracked & logged. At some point of time, i would like to see who changed which file inside this. Will your code help achieve this?

How easy it is to view the expected output(user who changed/file that was changed/what was changed)?

Score:5
in flag

Yes -

inotifywait - wait for changes to files using inotify

Example:

while inotifywait -e modify /var/log/my_log; do
  if tail -n1 /var/log/my_log | grep error; then
    write_email_to_support
  fi
done

For your specific use case you can use -m (monitor) or -d (daemon, same as monitor, but run in background) and output (-o) to some log file:

#!/bin/bash
inotifywait -e create,modify -m /var/lib/docker/volumes/shared/_data -o /var/log/shared_data_log
  • Add -r to make inotfiywait watch changes recursively
  • You can use --format ... to specify an output format.
  • It is not possible to see who create or changed a file. That is a limitation of the file system.

See man inotifywait for more options.

Geek Favour avatar
vn flag
Who created/Edited a file is an important thing that i am looking for in this requirement. Do you recommend any other UI based tools? This code that you have shared works great. Just tested it out. CREATE/MODIFY it displays great.
pLumo avatar
in flag
It is simply not possible to know created / modified a file. You can know the owner, but that does not mean anything.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.