21.8 本章习题
[root@study ~]# ls /etc/{passwd,shadow,group} > important.file [root@study ~]# find /usr/sbin /usr/bin -perm /6000 > important.file[root@study ~]# vim md5.checkfile.sh #!/bin/bash for filename in $(cat important.file) do md5sum $filename > finger1.file done [root@study ~]# sh md5.checkfile.sh [root@study ~]# chattr +i finger1.file[root@study ~]# vim md5.checkfile.sh #!/bin/bash if [ "$1" == "new" ]; then for filename in $(cat important.file) do md5sum $filename > finger1.file done echo "New file finger1.file is created." exit 0 fi if [ ! -f finger1.file ]; then echo "file: finger1.file NOT exist." exit 1 fi [ -f finger_new.file ] && rm finger_new.file for filename in $(cat important.file) do md5sum $filename > finger_new.file done testing=$(diff finger1.file finger_new.file) if [ "$testing" != "" ]; then diff finger1.file finger_new.file | mail -s 'finger trouble..' root fi [root@study ~]# vim /etc/crontab 30 2 * * * root cd /root; sh md5.checkfile.sh
Last updated