How to install ClamAV (Antivirus) & ClamTK on Linux
Linux is known for its high standards of security & there are very low amount of viruses that has been known to infect a Linux system. But in the recent times as technology is moving forward at rapid pace, we are seeing that trojans, malware etc are also making it to Linux space & many users, especially enterprises with production servers on Linux, are looking for a Antivirus programs for secure their installations.
To address such a concern, we will discuss in this article about how to install Clam Antiivirus & its GUI ClamTK. Clam is an open source antivirus engine that is used to detect viruses, trojans & other malwares. It was initially designed as email scanning gateway on Unix but it has since then evolved as a solution for securing other OS & applications.
Recommended Read: Easy way to integrate Apache with modsecurity on Ubuntu
ClamAV is basically a CLI based program but in this tutorial, we will learn to setup Clam with a GUI frontend known as Clamtk & will also setup a daily scan of the Centos/RHEL & Ubuntu systems.
For RHEL/CentOS systems
We need to have EPEL repositories enabled as Clam pacakges are availble via EPEL repository. Based on your OS & architecture, execute one of the following commands to install EPEL repository on your CentOS/RHEL systems,
$ sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
RHEL/CentOS 6 (64 Bit)
$ sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
RHEL/CentOS 6 (32 Bit)
$ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
For Ubuntu System
No requirements as the Clam packages are available with the default repositories.
( Recommended Read : Beginner’s guide to SELINUX )
Install ClamAV on RHEL/CentOS
Once the epel repositories have been enabled, we can install ClamAV using yum command. To install Clam anti-virus, execute the following command via your terminal,
$ sudo yum install clamav clamd
Next we will star the Clam service & set to enable it at boot time,
$ sudo service clamd start OR sudo systemctl start clamd
$ sudo chkconfig clamd on OR sudo systemclt enable clamd
Now we will update the Clam AV’s signatures to the latest available,
$ sudo /usr/bin/freshclam
This will update the signature database to latest, also Clam AV will update daily as a cronjob is created by default under ‘/etc/cron.daily/freshclam’.
ClamAV installation on Ubuntu
Installation of Clam AV on Ubuntu is pretty simple, open terminal & excute the following command,
$ sudo apt-get install clamav
Now to update the AV signature database, run the following commands
$ sudo freshclam
That’s it, Clam AV is now now ready to work but before we do that we will install GUI for Clam AV.
Installing GUI for ClamAV
We will be using Clam TK as GUI frontend for Clam AV, its lightweight & very easy to use. To install it on CentOS/RHEL, we can use yum
$ sudo yum install clamtk
& similarly for Ubuntu, we can run
$ sudo apt-get install clamtk
& we will have ClamTK installed on our systems but if for some reasons its not installed, we can also grab the rpm & deb files from the ClamTK websites.
To get the packages files, visit ClamTK Official Website & under the download section, you will the package file for CentOS 6 & 7 and for Ubuntu as well, along with other Linux distributions.
Download the required file & install it using rpm,
$ sudo rpm -ivh clamtk-5.25-1.el7.noarch.rpm
or if installing it on Ubuntu, run
$ sudo dpkg -i clamtk_5.25-1_all.deb
Setting up a daily scan
To setup a daily scan, we can create a cron job that will be executed daily on systems. To do this, we will create a file named ‘daily_scan’ under ‘/etc/cron.daily/’ ,
$ sudo vim /etc/cron.daily/daily_scan
& will add the following line to the file
/usr/bin/clamscan -i -r /home >> /var/log/ClamAV/daily_scan.log
here ‘/home’ is the directory that will be scannned & ‘/var/log/ClamAV/daily_scan.log’ is the file where logs for the scan will be created. You can also excute the above mentioned command to start a scan from your teminal or if you want to start a scan using GUI, use ClamTK.
That completes our tutorial on setting ClamAV & its GUI frontend, ClamTK. If you have any queries on your mind or are facing some issue while installation, please do let us know using the comment box down below.