Home CentOS How To Install ClamAV Antivirus On CentOS

How To Install ClamAV Antivirus On CentOS

By sk
Published: Last Updated on 4.9K views

This brief guide explains how to install and use the ClamAV antivirus to protect your Linux server or desktop. ClamAV is an open source antivirus software for detecting viruses and malware on Linux platforms. It designed especially for e-mail scanning on mail gateways. It provides a number of utilities including a flexible and scalable multi-threaded daemon.

Features

  • Licensed under the GNU General Public License, Version 2 ;
  • POSIX compliant, portable ;
  • Fast scanning ;
  • Supports on-access scanning (Linux and FreeBSD only).

Install ClamAV in CentOS

For demonstration purpose, we are using Centos 6.4 64bit edition. Before we can do proceed, you must ensure that you have the EPEL yum repository enabled. To do this, do the following:

a) Check architecture

# uname -a

b) Know OS version

# cat /etc/redhat-release

For more details to know about your distribution version and architecture, refer the following guide.

c) Now enable EPEL  repository

CentOS 6.x 32-bit:

# rpm –ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

CentOS 6.x 64-bit:

# rpm –ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

d) Check the repository list.

# yum repolist

Now Install ClamAV as shown below.

1 - Install required ClamAV packages

 # yum install clamav clamd

2 - Start the clamd service and set it to auto-start

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

3 - Update the virus definitions database using command:

# /usr/bin/freshclam

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

4 - Set the cron job on a daily / hour / weekly to perform scan . In below example , we are going to create a cronjob on daily  to scan the folder /home/

# vi /etc/cron.daily/dailyscan
#!/bin/bash
SCAN_DIR="/home"
LOG_FILE="/var/log/clamav/dailyscan.log"
/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE

5 - Set the executable permission

# chmod +x /etc/cron.daily/dailyscan

Reference links:

You May Also Like

1 comment

Tony Esposito September 11, 2019 - 2:07 am

Not sure what the first # /etc/init.d/clamd on does …

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More