Install ClamAV Antivirus on CentOS /RHEL

What is ClamAV ?

ClamAV is an open source (GPL) antivirus engine designed for detecting Trojans, viruses, malware and other malicious threats on Linux. In this article, we will only be configuring ClamAV to run scheduled/on-demand scans; not resident scans.

Before we begin installation of ClamAV, we need to install and enable EPEL (Extra Packages for Enterprise Linux) repository.

Steps to Install ClamAV Antivirus on CentOS

You can directly download the latest Source form the official site and compile and install it.

Step 1. Install EPEL Repository.

CentOS / RHEL 64bit

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

CentOS / RHEL 32bit

rpm -Uvh http://mirror.overthewire.com.au/pub/epel/6/i386/epel-release-6-8.noarch.rpm

Step 2. Install required ClamAV packages.

yum -y install clamav clamd

After completion of installation, Start the clamd service and set it to auto-start.

/etc/init.d/clamd on
chkconfig clamd on
/etc/init.d/clamd start

Step 3. Update ClamAV’s signatures

/usr/bin/freshclam

Note: ClamAV will update automatically, as part of /etc/cron.daily/freshclam.

A. Daily Scan Scheduling

Create a new cron file in /etc/cron.daily/ directory. If you want to run scan weekly, then file location will be /etc/cron.weekly/

vim /etc/cron.daily/clamav_scan

Add following piece of code into clamav_scan file.

#!/bin/bash
SCAN_DIR="/home"
LOG_FILE="/var/log/clamav/weeklyscan.log"
/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE

Exit vim editor and give this script executable permissions.

chmod +x /etc/cron.daily/clamav_scan

View more posts in this category !!!

Install clamav antivirus in Ubuntu.

LinuxTweaks

Linuxtweaks Blog helping Server Admin to Manage their servers, Desktop users for making more friendly with linux. Tutorials , guides and tips for linux server maintenance. Here you can learn how to tweak linux servers with code and how to manage it properly.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *