How to install & use ClamAV on FEDORA

Update
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.
#Example

      2-uncomment (remove the # in front of) the line “DNSDatabaseInfo current.cvd.clamav.net”

# 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: current.cvd.clamav.net
DNSDatabaseInfo current.cvd.clamav.net

      3-Localized the virus database source to the nearest one by adding a new line “DatabaseMirror db.XY.clamav.net”, 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 http://www.iana.org/cctld/cctld-whois.htm for the full list.
# You can use db.XY.ipv6.clamav.net for IPv6 connections.
#DatabaseMirror db.XY.clamav.net
DatabaseMirror db.vn.clamav.net

      4-be sure that the following line is uncomment

DatabaseMirror database.clamav.net

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.

    Like

  2. Den says:

    Outstanding .Old guy 780 years old. I understood perfectly

    Thankyou,
    Den

    Like

  3. Ganesh says:

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

    Like

  4. ren says:

    Thanks! This is great help!

    Like

  5. maheshkumar india says:

    really a superb and simple presentation. keep it up

    Like

  6. Alejandro says:

    Thanks!!!

    Like

  7. azare says:

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

    Like

  8. Truls Sjurelv says:

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

    Like

  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.

    Like

    • 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.
      Laurent

      Like

  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…

    Like

  11. Người Đến Từ Bình Dương says:

    Reblogged this on Người Đến Từ Bình Dương.

    Like

  12. Thanks for the instruction, super!!!

    Like

  13. Thaaanks!
    I think you just forget teach about save the changes in Vi.
    So:

    Just press ESC and write
    :wq

    Like

    • 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

      Like

  14. […] Ittechnik3, Server-world, […]

    Like

  15. Brian Hurren says:

    can use gedit instead of vi..much easier

    Like

    • 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.

      Like

  16. Lucas Jensen says:

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

    Like

Leave a reply to LaurentD Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.