How to install & use ClamAV on FEDORA

This procedure work for FEDORA 15, 16, 17, 18 and 19

Even if, until now, you don’t really need to install an Antivirus on a home desktop (especially if you use only non-Windows System) you may need to check some USB flash drive or optical disk for virus before exchange files with a Windows “Friend”.

First of all, perform a system update under superuser
[root@nowin]# yum update -y

Then install ClamAV
[root@nowin]# yum install clamav freshclam
[root@nowin]# yum install clamav clamav-update
(Thanks to Helio Zwi for the update)

Edit the configuration file with your favorite editor
[root@nowin]# vi /etc/freshclam.conf
and perform the following change:

      1-add a # in front of “Exemple” (to comment/disable it)

# Comment or remove the line below.

      2-uncomment (remove the # in front of) the line “DNSDatabaseInfo”

# Use DNS to verify virus database version. Freshclam uses DNS TXT records
# to verify database and software versions. With this directive you can change
# the database verification domain.
# WARNING: Do not touch it unless you're configuring freshclam to use your
# own database verification domain.
# Default:

      3-Localized the virus database source to the nearest one by adding a new line “DatabaseMirror”, and changing XY by your 2 characters country code, here for Vietnam it will be:

# Uncomment the following line and replace XY with your country
# code. See for the full list.
# You can use for IPv6 connections.

      4-be sure that the following line is uncomment


Now you can make your first Virus Database update, if everything is ok you may have something like this:
[root@nowin]# freshclam
ClamAV update process started at Sun Apr 17 09:17:12 2011
main.cvd is up to date (version: 53, sigs: 846214, f-level: 53, builder: sven)
daily.cvd is up to date (version: 13004, sigs: 105394, f-level: 60, builder: guitar)
bytecode.cvd is up to date (version: 143, sigs: 40, f-level: 60, builder: edwin)

You may received an error message if you try to frechclam under your user:
[me@nowin]$ freshclam
ERROR: Can't create temporary directory /var/lib/clamav/clamav-0f9ef994d9a44c7f9b939251c41f3c86
Hint: The database directory must be writable for UID 500 or GID 500

then just run the following command as root to give you the right:
[root@nowin]# chown -R 500:500 /var/lib/clamav
[root@nowin]# chmod -R 755 /var/lib/clamav

Of course if the UID GID are different from 500 , just put your ID in chown command, then freshclam again with your user.

It’s the moment of truth ! to scan a USB Flash drive you may use:
[me@nowin]$ clamscan --infected --bell --scan-archive --max-recursion=10 -r /media -l ~/clamav.log
This just list all infected files found.

To remove the infected files:
[me@nowin]$ clamscan --remove=yes --bell --scan-archive --max-recursion=10 -r /media -l ~/clamav.log

Your target media to scan may be mounted in another point so check in:
ls /media
ls /opt
ls /mnt

Don’t forget the man page for more help.

Be safe…

What next:

    Create a scheduled task to daily update your virus definition (coming soon)
    Create your own virus definition repository for local/internal update (coming soon)


23 Responses to How to install & use ClamAV on FEDORA

  1. Helio Zwi says:

    Correction: freshclam is provided (as of 4/29/11) by clamav-update.
    In other words, the installation line should be

    # yum install clamav clamav-update

    Everything else works perfectly fine.

  2. Den says:

    Outstanding .Old guy 780 years old. I understood perfectly


  3. Ganesh says:

    Thanks, alot .., can you tell about how we can get clamav gui interface

  4. ren says:

    Thanks! This is great help!

  5. maheshkumar india says:

    really a superb and simple presentation. keep it up

  6. Alejandro says:


  7. azare says:

    Thanks. With the steps above, I got it installed.

  8. Truls Sjurelv says:

    These instructions work great also on Fedora 19, thank you!

  9. Jim says:

    Thanks for the instruction, this works good in Fedora 19.
    By the way, if you run “freshclam” and you encounter those error – you can simply type “sudo freshclam” without changing the permissions.

    • LaurentD says:

      Hi Jim,
      You’re right, however i had this mention in order for be able to launch this command using user permission through a cron job for exemple.

  10. cabra219 says:

    TNX for the explanation! this made me use ClamAV in an easy way.

    because more and more oranizations demand proper updated and anti-virus-ed systems I now run both on Fedora 19, almost 20…

  11. Thanks for the instruction, super!!!

  12. Thaaanks!
    I think you just forget teach about save the changes in Vi.

    Just press ESC and write

    • LaurentD says:

      Thanks for your feedback, this post was mainly focused on ClamAV, assuming that the reader already know how to perform basic operations on his favorite editor. That’s could be a good topic for a future post. Thanks, Laurent

  13. Brian Hurren says:

    can use gedit instead of vi..much easier

    • LaurentD says:

      Sure, we can always use a GUI text editor, but i always try show ways that are not desktop environment dependent. Thanks for your feedback.

  14. Lucas Jensen says:

    You can find updated instructions that also show how to setup periodic antivirus scans available here.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: