#!/bin/bash # Write By [email protected] md5sum="/usr/bin/md5sum" md5f=SysCheck-`date +%F`.md5 fs="/etc /etc/sysconfig /bin /sbin /usr/bin /usr/sbin" for d in $fs do for f in `ls $d` do $md5sum $d/$f >> $md5f done done
這裡有幾個注意事項:
1、md5sum文件一定要提前備份在另外一個安全的地方
2、對於生成的md5f(如SysCheck-2008-01-27.md5)文件,也一定要存儲在另外一個安全的地方,在校驗的時候再下載到本地使用
[root@lapp ~]# ./m5 -c SysCheck-2008-01-27.md5 |more /etc/adjtime: OK /etc/aliases: OK /etc/aliases.db: OK /etc/anacrontab: OK /etc/at.deny: OK /etc/auditd.conf: OK /etc/audit.rules: OK /etc/auto.master: OK /etc/auto.misc: OK /etc/auto.Net: OK /etc/bashrc: OK /etc/bg5ps.conf: OK /etc/bg5ps.conf.zh_CN: OK /etc/bg5ps.conf.zh_CN.GB2312: OK /etc/bg5ps.conf.zh_TW: OK /etc/bg5ps.conf.zh_TW.Big5: OK