Linux 下杀毒软件 clamav 0.104.2 离线安装及测试(CentOS7)
Linux 下杀毒软件 clamav 0.104.2 离线安装及测试(CentOS7)
1.下载安装
2. 配置
3. 运行
Linux 下杀毒软件 clamav 0.104.2 离线安装及测试(CentOS7)
1.下载安装
clamav 官网下载 clamav-0.104.2.linux.x86_64.rpm
将该文件上传至服务器,安装命令如下:
rpm -ivh --prefix=/usr/local/clamav clamav-0.104.2.linux.x86_64.rpm
2. 配置
添加用户组和组成员
groupadd clamav
useradd -g clamav clamav
创建日志目录和病毒库目录
mkdir -p /usr/local/clamav/logs
mkdir -p /usr/local/clamav/update
创建日志文件
touch /usr/local/clamav/logs/clamd.log
touch /usr/local/clamav/logs/freshclam.log
文件授权
chown clamav:clamav /usr/local/clamav/logs/clamd.log chown clamav:clamav /usr/local/clamav/logs/freshclam.log chown clamav:clamav /usr/local/clamav/update
修改配置文件
cp /usr/local/clamav/etc/clamd.conf.sample /usr/local/clamav/etc/clamd.conf
cp /usr/local/clamav/etc/freshclam.conf.sample /usr/local/clamav/etc/freshclam.conf
文件1:clamd.conf
vim /usr/local/clamav/etc/clamd.conf
#Example //注释掉这一行 #添加以下内容 LogFile /usr/local/clamav/logs/clamd.log PidFile /usr/local/clamav/update/clamd.pid DatabaseDirectory /usr/local/clamav/update
文件2:freshclam.conf
vim /usr/local/clamav/etc/freshclam.conf
#Example //注释掉这一行 #添加以下内容 DatabaseDirectory /usr/local/clamav/update UpdateLogFile /usr/local/clamav/logs/freshclam.log PidFile /usr/local/clamav/update/freshclam.pid
将这两个文件复制一下:
cp /usr/local/clamav/etc/*.conf /usr/local/etc/
3. 运行
-
下载病毒库文件并上传到目录 /usr/local/clamav/update
注:也可以在有网络的机器上运行如下命令更新病毒库:
/usr/local/clamav/bin/freshclam
2.配置库文件路径
vim /etc/ld.so.conf
追加一行:
/usr/local/clamav/lib64
更新生效:
ldconfig
如果最后运行时仍然报错:
clamscan: error while loading shared libraries: libclamav.so.9: cannot open shared object file: No such file or directory
则说明配置没有生效。
3.创建命令软件链接
ln -s /usr/local/clamav/bin/clamscan /usr/local/bin/clamscan
运行使用
-
卸载程序
-
rpm remove clamav
clamscan -r --bell -i 路径 杀毒 clamscan -r –remove 路径 扫描并清除 clamscan -r --bell -i /opt/1/ --move /tmp/ 扫描并移动病毒和感染文件到指定目录 -r 递归扫描子目录 -i 筛选感染文件 –bell 病毒检测的侦查 –copy 目录 将受感染的文件复制到目录
ClamAV扫描病毒
##扫描文件 clamscan targetfile ##递归扫描home目录,并且记录日志 clamscan -r -i /home -l /var/log/clamscan.log ##递归扫描home目录,将病毒文件删除,并且记录日志 clamscan -r -i /home --remove -l /var/log/clamscan.log ##建议##扫描指定目录,然后将感染文件移动到指定目录,并记录日志 clamscan -r -i /home --move=/opt/infected -l /var/log/clamscan.log
周期自动扫描病毒
##每天凌晨11点进行文件扫描 crontab -e 0 23 * * * root /usr/local/bin/clamscan.sh ##配置扫描文件 vim /usr/local/clamscan.sh clamscan -r -i /home --move=/opt/infected -l /var/log/clamscan.log