1

How would you monitor a directory on a Linux machine to check if there was a user (or someone from the network) who attempted to access it?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
xralf
  • 16,149
  • 29
  • 101
  • 149

2 Answers2

3

inotify like so

inotifywait -m -e modify,create,delete -r /var/www >> /var/log/i-see-www 2>&1

assuming you meant "worked in" when you said "access", simply listing or reading files .. that'd be harder to do.

flowtron
  • 336
  • 2
  • 6
3

You can use auditd (audit) to monitor file access , after starting the service a log file will be registered under /var/log/audit/audit.log

To set a watch on a file, run :

sudo auditctl -w /path/to/file

To check it , run:

sudo ausearch -f /path/to/file

A detailled tuto can be found on Arch-linux-Wiki

GAD3R
  • 63,407
  • 31
  • 131
  • 192