Command | md5sum /etc/passwd |
Result | c1ada30d1bad6c315a9fca99531fed9d /etc/passwd |
Command 1 | useradd test |
Command 2 | md5sum /etc/passwd |
Result | 0411041fe041586c71cf206a32ae3135 /etc/passwd |
echo "CHECK MD5 CHECKSUMS..."What this file will do each time it is run, is redo the checksum for all the original files, compare the results to the original baseline, and then it will either say that nothing has changed or it will show you which files have changed.
md5sum `cut -c 35- /root/check/list.md5` >> /tmp/keep
if [ `diff /root/check/list.md5 /tmp/keep | wc -l` = "0" ]
then
echo "All seems fine.."
else
diff /root/check/list.md5 /tmp/keep
fi
rm -rf /tmp/keep
[root@syplh check]# useradd testmd5Here we can see that these 3 files have changed, which is normal for adding a new user.
[root@syplh check]# /root/check/md5check
CHECK MD5 CHECKSUMS...
1,3c1,3
< 0411041fe041586c71cf206a32ae3135 /etc/passwd
< 53a817891bdbbd94c4464ec2943ab77f /etc/group
< 626996458be34d99994392cb317efde9 /etc/shadow
---
> a0807d05498d456d7a944a1b9d66e89e /etc/passwd
> 0bf5488fae10bd02992096df113f38f6 /etc/group
> bd5bfae3d83921e33b8ea45cbfff3d9b /etc/shadow
[root@syplh check]#