How to Install ClamAV

In this article we will guide you through the installation of ClamAV on CentOS.

Install CalmAV:

To install require ClamAV packages,Use the command below:

yum install clamav clamd

Start the clamd service and set it to auto-start

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

Configure Daily Scan:

In this example, we will configure a cronjob to scan the /home/ directory every day:

To create cron file:

vim /etc/cron.daily/manual_clamscan

Add the following to the file above. Make sure to change SCAN_DIR to the directory that you want to scan:

/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE

Give your  cron script executable permissions:

chmod +x /etc/cron.daily/manual_clamscan

Done! That should be the minimum required to install ClamAV and also to scan the server using ClamAV.

Some Useful Commands to Scan server using ClamAV:

To check files in the all users home directories:

# clamscan -r /home

To check files in the USER home directory and move infected files to another folder:

# clamscan -r --move=/home/USER/VIRUS /home/USER

To check files in the USER home directory and remove infected files (WARNING: Files are deleted permanently)

# clamscan -r --remove /home/USER

To see more options:

# clamscan --help
If your ClamAV scan process hangs,You can check our article on this ClamAV problem.