在Debian系统中,可借助inotify工具监控文件系统事件实现安全审计,核心操作如下:
sudo apt install inotify-tools
安装inotify-tools软件包。inotifywait -m -r -e create,delete,modify /path/to/directory
命令递归监控指定目录(如/etc
、/var/log
)的文件创建、删除、修改事件。/etc/passwd
的变化,命令为inotifywait -m -e modify /etc/passwd
。/var/log/inotify.log
),便于后续审计。journalctl
或dmesg
查看系统日志,关联inotify事件与系统行为。rsync
、fail2ban
)触发告警或隔离操作。fs.inotify.max_user_watches
)避免监控资源耗尽。--exclude '\.swp'
)。注:inotify仅提供事件监控,需结合其他安全工具(如auditd)实现完整审计。
参考来源: