Table of Contents
This article will give you a script to help you install clamav on centos faster, instead of having to run each command line. I wrote it as a function, you can copy this function into any of your other scripts to use.
There are some people who say that using Linux is safe, and that ordinary viruses can not work on Linux. That is completely wrong. Previously, people could say that because of the number of machines running Linux is relatively small. So hackers do not bother to write malicious code running on Linux.
But today, the number of machines using Linux has increased. And you need to protect yourself against the dangers. There are a number of antivirus solutions that are well known for Linux users, but not everyone has a lot of money. So we need free antivirus solutions – it’s clamav.
Script install clamav
Copy the content below to a file on the server and name it install_clamav.sh (or whatever name you want).
#!/bin/bash
# Script author: Danie Pham
# Script site: https://devopslite.com
# Script date: 31-12-2017
# Script ver: 1.0
# Script use to install clamav on CentOS 6.x
# Function install clamav
f_install_clamav () {
# Command install epel-release package
yum install epel-release -y
# Command install clamav package
yum install clamav clamav-db clamd -y
# Set clamav auto start after reboot
/etc/init.d/clamd on
chkconfig clamd on
# Update database for clamav
/usr/bin/freshclam
# Start clamav
/etc/init.d/clamd start
# Exclude some wrong signature of clamav
cat > /var/lib/clamav/local.ign2 <<"EOF"
PUA.Win.Trojan.EmbeddedPDF-1
PUA.Pdf.Trojan.EmbeddedJavaScript-1
PUA.Pdf.Trojan.EmbeddedJS-1
Heuristics.OLE2.ContainsMacros
EOF
# Restart clamav
/etc/init.d/clamd restart
}
# Main function
f_main () {
# Call f_install_clamav function (you can use this method in other script)
f_install_clamav
}
f_main
exitYou can download the script here.
Use script install clamav
After you finish copying the script, assign permissions to the script as follows:
chmod 700 install_clamav.shRead more: Script send email warning ssh login
Next, just run the command below to perform the clamav installation:
./install_clamav.sh
After the script done the installation, will be notified as the image below.

Conclusion
With the installation of clamav, you can feel secure about your Linux server or you can use it right on your personal computer. Of course clamav is a free solution and it can not be compared to commercial solutions like Bitdefender or Symantec …
(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).