第21章 软件安装:源代码与 Tarball 练习题

情景模拟题

请依照下面的方式来创建你系统的重要文件校验值,并每日进行比对。

  1. 将 /etc/{passwd,shadow,group} 以及系统上面所有的 SUID/SGID 文件建立文件列表,该列表文件名为 important.file
ls /etc/{passwd,shadow,group} > important.file
find /usr/sbin /usr/bin -perm /6000 >> important.file
  1. 通过这个文件名列表,以名为 md5.checkfile.sh 的文件名去建立校验值,并将该校验值文件 finger1.file 设置成不可修改的属性
vim md5.checkfile.sh
#! /bin/bash
for filename in $ (cat important.file)
do 
	md5sum $filename >> finger1.file
done

sh md5.checkfile.sh
chattr +i finger1.file
  1. 通过相同的机制去建立后续的分析数据为 finger_new.file,并将两者进行比对,若有问题则发生 email 给 root :
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 >> finger1.file
done

testing = $(diff finger1.file finger_new.file)
if ["$testing" != ""]; then
	diff finger1.file finger_new.file | mail -s 'finger trouble..' root
fi

vim /etc/crontab
30 2 * * * cd/root; sh md5.checkfile.sh
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值