Script install clamav on CentOS 6

by Daniel Pham
Published: Updated:

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
Use script to install clamav

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

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 …

(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).

0 0 votes
Article Rating

You may also like

Notify of
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.



Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 – All rights reserved.

Please write sources “” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Would love your thoughts, please comment.x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.