Clamav Antivirus-Install on Amazon Linux (EC2)

IT & Software | Operating Systems
ClamAV is an Opensource Antivirus option for Linux/Unix O/S and protects your system against Trojans, malware and other security threats.

Linux is known for its security and believed as one of the most secure O/S. You might have heard people talking about how secure it is, and guaranteed for no Virus Attack on Linux Operating Systems. But in reality, Linux Operating Systems are also being infected by viruses.

If you want to protect your Linux O/S, Network or VPC and looking for an Open-Source Antivirus Software, you can go for ClamAV.
No attachments
Step 1- Add Epel repository to download ClamAV in your Amazon Linux.

     $ sudo amazon-linux-extras install epel

Step 2- Install ClamAV and Clamd using YUM Command

    $ sudo yum install clamav clamd -y

Step 3-  Remove Example Strings from the Configuration file.

   $ sudo sed -i -e “s/^Example/#Example/” /etc/clamd.d/scan.conf

   $ sudo sed -i -e “s/^Example/#Example/” /etc/freshclam.conf

Step 4-  Run Virus Defination Database update

  $ sudo freshclam

Step 5- Uncomment the following line in scan.conf

Open the scan.conf file using nano command

  $ nano /etc/clamd.d/scan.conf

Un-comment the following line by removing #

  #LocalSocket /var/run/clamd.scan/clamd.sock

After removing # from the above line save and exists the file by pressing CTRL+O and CTRL+X

Step 6 – Start Clamd Service

 $ sudo systemctl start clamd@scan

Also, run the following command to run the service automatically if system reboots.

 $ sudo systemctl enable clamd@scan

Step 7- Disable or Modify SELINUX

 To disable SELINUX run following command

   $ setenforce 0

 To modify SELINUX to Allow ClamAV run following command

  $ sudo setsebool -P antivirus_can_scan_system 1
  $ sudo setsebool -P clamd_use_jit 1

To Verify SELINUX run following Command

 $ sudo getsebool -a | grep antivirus

It is OK if you get the below result.

antivirus_can_scan_system –> on
antivirus_use_jit –> off

Step 8- Setup a Cron job to schedule and update and scan.

Run the following command to setup a cron job, to learn more about cron job read my article Scheduling Cron job in Linux

 $ crontab -e

Add the following line in the Cron.

20  02* * * /usr/bin/freshclam > /var/log/clamav/freshclam.log
30   02* * * /usr/bin/clamscan -ir / -l /var/log/clamav/clamd.log –copy=/usr/local/src/virusdetectiondirectory

Note: Create the directories /var/log/clamav/ and /usr/local/src/virusdetectiondirectory in your Linux Box.

on April 21st, 2020 (10:10 pm)
All coments
This job has not been commented yet.