Installing ClamAV Anti-Virus on CentOS And Scanning For Viruses on The Server
By installing ClamAV anti-virus on the server, you can scan for viruses on your server. Below we will try to explain how to install and scan.
Since there is no ClamAV in the standard CentOS libraries, let’s start by adding the EPEL repo to CentOS as the best way;
yum install epel-release -y
Then, with the command below, ClamAV anti-virus and Clamav Clamd Deamon is installed;
yum install clamav clamd
With the following commands, we set Clamd to start automatically with the system and start it;
chkconfig clamd on
/etc/init.d/clamd start
Let’s update the ClamAV virus database with the following command;
/usr/bin/freshclam
With the command below, we can start scanning and find the infected file and write it to the specified log file. We could also have a direct deletion, but in this case, serious problems can occur with the deletion of various files related to the system. Therefore, it would be more logical to detect infected files and perform the manual operation.
clamscan --infected --recursive --log=/tmp/clamscan.log /
To have a daily automatic scan, you can create a script as follows and define it as crona;
First, let’s open it to create the script file;
nano /etc/cron.daily/otomatik_clamscan
Then let’s record the following content into it;
#!/bin/bash
SCAN_DIR="/"
LOG_FILE="/var/log/clamav/manual_clamscan.log"
/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE
Then let’s make the file executable with the following command;
chmod +x /etc/cron.daily/otomatik_clamscan
I hope it has been a useful article.
