Chinaunix首页 | 论坛 | 博客
  • 博客访问: 175711
  • 博文数量: 159
  • 博客积分: 7007
  • 博客等级: 准将
  • 技术积分: 1750
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-17 15:05
文章分类

全部博文(159)

文章存档

2010年(39)

2009年(106)

2008年(14)

我的朋友

分类:

2008-12-26 10:00:21

[root@apache ~]# more /home/nihao/test.sh
#!/bin/bash
#
####################################################
# Purpose: check ! root
# Author: Kook.liu , E-Mail ( qsblj AT yahoo DOT com)
# Date: 2005/08/04
####################################################
#
####################################################
for id in $(awk -F: '{ if($3 == 0 && $1 != "root") print $1 }' /etc/passwd)
do
        mail -s "Root Access Alert" root@nihao.cn << EOF
*********************************************
*ALERT! Longin ID $(echo ${id}) has uid 0
*$(date "+Dectected on Date:%Y%m%d Time:%r")
*********************************************
EOF
done
此shell程序是自动检测id为0的用户,如果有人把普通用户的passwd里给修改为0了,它就会给用户发邮件通知用户
[root@apache ~]# crontab -l
*/5 * * * * /home/nihao/test.sh
加入crontab里,使其每5分钟执行一次

阅读(394) | 评论(0) | 转发(0) |
0

上一篇:shell使用总结

下一篇:问候早中晚

给主人留下些什么吧!~~