Script install clamav on CentOS 6

Share this post to your friends !

WriteBash - 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 (or whatever name you want).

# Script author: Danie Pham
# Script site:
# 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

    # Start clamav
    /etc/init.d/clamd start

    # Exclude some wrong signature of clamav
    cat > /var/lib/clamav/local.ign2 <<"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)


You can download the script here.

Use script install clamav

After you finish copying the script, assign permissions to the script as follows:

chmod 700

Read moreScript send email warning ssh login

Next, just run the command below to perform the clamav installation:

script-install-clamav-on-centos-6-01 Script install clamav on CentOS 6
Use script to install clamav

After the script done the installation, will be notified as the image below.

script-install-clamav-on-centos-6-02 Script install clamav on CentOS 6
The result when script finished


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 …

If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.

Share this post to your friends !
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

single post bottom banner
«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.