前言:
ClamAV 杀毒是Linux平台最受欢迎的杀毒软件,ClamAV属于免费开源产品,支持多种平台,如:Linux/Unix、MAC OS X、Windows、OpenVMS。ClamAV是基于病毒扫描的命令行工具,但同时也有支持图形界面的ClamTK工具。ClamAV主要用于邮件服务器扫描邮件。它有多种接口从邮件服务器扫描邮件,支持文件格式有如:ZIP、RAR、TAR、GZIP、BZIP2、HTML、DOC、PDF,、SIS CHM、RTF等等。ClamAV有自动的数据库更新器,还可以从共享库中运行。命令行的界面让ClamAV运行流畅。Clamav下载:http://www.clamav.net/downloads
1.下载安装包
[root@XiaoFeng opt]# wget http://www.clamav.net/downloads/production/clamav-0.99.4.tar.gz [root@XiaoFeng opt]# tar -zxvf clamav-0.99.4.tar.gz[root@XiaoFeng opt]# cd clamav-0.99.4
BashCopy2.创建用户和组
[root@XiaoFeng clamav-0.99.4]# useradd -s /sbin/nologin clamav #创建clamav运行用户和组
BashCopy3.开始配置目录
[root@XiaoFeng clamav-0.99.4]# ./configure --prefix=/usr/local/clamav[root@XiaoFeng clamav-0.99.4]# make && make install[root@XiaoFeng clamav-0.99.4]# mkdir /usr/local/clamav/logs #(创建日志存放目录)[root@XiaoFeng clamav-0.99.4]# mkdir /usr/local/clamav/updata #(创建clamav 病毒库目录)[root@XiaoFeng clamav-0.99.4]# cd /usr/local/clamav/etc[root@XiaoFeng etc]# mv clamd.conf.sample clamd.conf[root@XiaoFeng etc]# mv freshclam.conf.sample freshclam.conf
BashCopy4.修改配置文件
[root@XiaoFeng etc]# vim clamd.conf# Example 注释掉这一行LogFile /usr/local/clamav/logs/clamd.log #删掉前面的注释路径改一下PidFile /usr/local/clamav/updata/clamd.pid #删掉前面的注释路径改一下DatabaseDirectory /usr/local/clamav/updata #删掉前面的注释路径改一下[root@XiaoFeng etc]# vim freshclam.conf# Example 注释掉这一行DatabaseDirectory /usr/local/clamav/updataUpdateLogFile /usr/local/clamav/logs/freshclam.logPidFile /usr/local/clamav/updata/freshclam.pid
BashCopy5.创建日志文件
[root@XiaoFeng etc]# touch /usr/local/clamav/logs/freshclam.log[root@XiaoFeng etc]# chown clamav:clamav /usr/local/clamav/logs/freshclam.log[root@XiaoFeng etc]# touch /usr/local/clamav/logs/clamd.log[root@XiaoFeng etc]# chown clamav:clamav /usr/local/clamav/logs/clamd.log[root@XiaoFeng etc]# chown clamav:clamav /usr/local/clamav/updata
BashCopy6.使用方法
[root@XiaoFeng etc]# cd ../bin[root@XiaoFeng bin]# ./freshclam #(升级病毒库)[root@XiaoFeng bin]# ./clamscan --no-summary -ri /tmp #这个命令,只显示找到的病毒信息-r 递归扫描子目录-i 只显示发现的病毒文件--no-summary 不显示统计信息
BashCopy7.计划任务
实际生产环境应用
一般使用计划任务,让服务器每天晚上定时跟新和定时杀毒。保存杀毒日志,我的crontab文件如下
1 3 * ** /usr/local/clamav/bin/freshclam30 3 * * * /usr/local/clamav/bin/clamscan --infected -r / --remove -l /usr/local/clamav/logs/clamscan.log
BashCopy查询病毒结果