监控 /etc/passwd 个文件
Monitoring /etc/passwd file
我需要一个脚本来检查 /etc/passwd
文件中的任何修改,如果有修改,我会立即通过电子邮件收到提醒,告诉我已在 passwd
中添加或删除了一个用户] 文件
不使用 inotifywait 命令
您可以使用 inotifywait
实用程序,如下所示:
inotifywait -e modify /etc/passwd
inotifywait
将在写入所选文件后退出,因此您可以采取任何需要的操作。
您可以使用 md5sum 或 sha256 检查修改...
制作你的基本校验和,将其硬编码在一个 scrip
if [[ "$(sha256 /etc/passwd)" != "the hash of ori file" ]]; then
mail yourself
fi
您还可以在某处获得 /etc/passwd 的副本,以及 运行 您通过邮件发送的包含更改内容的差异
if [[ "$(diff /etc/passwd /root/passwdbackup)" != "" ]]; then
mail yourself
fi
我需要一个脚本来检查 /etc/passwd
文件中的任何修改,如果有修改,我会立即通过电子邮件收到提醒,告诉我已在 passwd
中添加或删除了一个用户] 文件
不使用 inotifywait 命令
您可以使用 inotifywait
实用程序,如下所示:
inotifywait -e modify /etc/passwd
inotifywait
将在写入所选文件后退出,因此您可以采取任何需要的操作。
您可以使用 md5sum 或 sha256 检查修改... 制作你的基本校验和,将其硬编码在一个 scrip
if [[ "$(sha256 /etc/passwd)" != "the hash of ori file" ]]; then
mail yourself
fi
您还可以在某处获得 /etc/passwd 的副本,以及 运行 您通过邮件发送的包含更改内容的差异
if [[ "$(diff /etc/passwd /root/passwdbackup)" != "" ]]; then
mail yourself
fi