How To Install ClamAV on Fedora 45

Install ClamAV on Fedora 45

Fedora has a reputation as a clean, security-minded distribution. SELinux is on by default, packages are fresh, and the defaults are sane. So why would anyone need an antivirus on it?

Because Linux malware is rarely aimed at Linux. A Fedora box often sits in the middle of other people’s files: a Samba share that Windows laptops write to, a mail relay, a web server that accepts uploads, a CI runner that unpacks artifacts from strangers. The risk is usually not that your server gets infected. The risk is that it becomes a carrier, passing a poisoned attachment or a trojanized archive to someone who is vulnerable.

That is where ClamAV earns its place. It is open source, scriptable, and light enough to run on a small VPS. It also behaves predictably, which matters more than almost anything else on a production machine.

Fedora 45 reached general availability on November 3, 2026, and ClamAV’s current stable branch is 1.5, with 1.5.5 as the latest release at the time of writing. The 1.4 LTS branch is still supported until August 2027. This guide covers installing ClamAV from Fedora’s repositories, wiring up signature updates, running a daemon, scheduling scans, handling SELinux, tuning resources, and fixing the errors that actually show up in practice.

What You Are Installing

Fedora splits ClamAV into several packages. This confuses people coming from Ubuntu, where clamav-daemon bundles most of the pieces. Knowing the layout saves time later.

Package Purpose
clamav The command-line scanner, clamscan, and core tools
clamav-freshclam The signature updater and its systemd service
clamd The scanning daemon, plus the clamdscan client
clamav-data The signature database directory and base files
clamav-lib Shared libraries

The basic scanner and updater come from clamav and clamav-freshclam, and the daemon is a separate clamd package. Fedora’s packaging also uses a templated service, clamd@scan, rather than a plain clamd.service. Remember that name, because it comes up again in the troubleshooting section.

Before You Start

A few checks first. They take a minute and prevent most of the weird problems.

Confirm the release and make sure you have root access through sudo:

cat /etc/fedora-release
sudo -v

Check memory. ClamAV loads its entire signature set into RAM when the daemon starts, and this is the number one surprise for people on small instances:

free -h

Plan for at least 2 GB of RAM if you intend to run clamd. The on-demand clamscan command also loads signatures on every run, so it needs similar memory for the duration of the scan, just not permanently.

Finally, bring the system current:

sudo dnf upgrade --refresh

Reboot if a new kernel landed. It is not strictly required for ClamAV, but a half-updated system makes later troubleshooting murkier.

Step 1: Install ClamAV on Fedora 45 with DNF

Start with the scanner and updater:

sudo dnf install clamav clamav-freshclam

Verify the install:

clamscan --version

You should see a version string followed by a signature database number and date. If the database field is missing or says the database is absent, that is expected at this stage. Signatures have not been downloaded yet.

Fedora’s repository version may trail upstream by a patch release or two. For most servers that is fine, and arguably preferable, since the package is tested against the rest of the distribution and patched through normal dnf upgrade runs. Upstream also publishes RPMs, but they install into /usr/local and ship without preconfigured freshclam.conf, clamd.conf, or service accounts, so you build all of that yourself. Unless you need a specific upstream feature, stay with the Fedora packages.

Step 2: Configure FreshClam for Signature Updates

An antivirus without current signatures is a placebo. FreshClam is the component that downloads them.

Open the configuration file:

sudo nano /etc/freshclam.conf

On many Fedora installs, the file contains an Example line near the top. If that line is active, FreshClam refuses to start as a safety measure. Comment it out or delete it:

#Example

Other settings worth reviewing:

DatabaseDirectory /var/lib/clamav
UpdateLogFile /var/log/freshclam.log
LogTime yes
Checks 24
DatabaseMirror database.clamav.net

Checks 24 means FreshClam looks for updates 24 times a day, roughly hourly. That is the commonly recommended cadence and it is gentle on the mirrors. Do not raise it. Hammering the mirrors can get your IP rate-limited or blocked, and you gain nothing, since signature releases are not that frequent.

Run the first update manually. This is important because the systemd service will not behave well until a database exists:

sudo freshclam

You should see main.cvd, daily.cld, and bytecode.cvd being downloaded. Together these are a few hundred megabytes, so give it a moment on slow links.

Now enable the background updater:

sudo systemctl enable --now clamav-freshclam.service
sudo systemctl status clamav-freshclam.service

If you ran freshclam manually while the service was already running, you may see a lock error. Stop the service, run the manual update, then start the service again.

Step 3: Run Your First Scan

With signatures in place, clamscan works immediately. Try a harmless directory first:

clamscan -r -i ~/Downloads

The flags matter:

  • -r recurses into subdirectories.
  • -i prints only infected files, which keeps output readable.

For a full summary at the end, the scan prints scanned files, infected count, data volume, and elapsed time. Note that elapsed time. It gives you a baseline for scheduling later.

You can test detection safely with the EICAR test string, an industry-standard harmless file that every scanner recognizes:

echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > /tmp/eicar.txt
clamscan /tmp/eicar.txt
rm /tmp/eicar.txt

The result should report Eicar-Signature FOUND (or a close variant). If a scanner finds nothing here, something is misconfigured, and no real-world scan can be trusted.

Step 4: Install and Configure the clamd Daemon

Running clamscan repeatedly is wasteful. Every invocation reloads the full signature set, which can take many seconds. On a mail server or upload handler scanning files all day, that is unacceptable.

The daemon loads signatures once and keeps them in memory. Clients then send files to it through a socket.

sudo dnf install clamd

Fedora keeps instance configs under /etc/clamd.d/. The one you need is scan.conf:

sudo nano /etc/clamd.d/scan.conf

As with FreshClam, comment out the Example line if present:

#Example

Then confirm or set these values:

LogFile /var/log/clamd.scan
LogTime yes
LocalSocket /run/clamd.scan/clamd.sock
LocalSocketGroup virusgroup
LocalSocketMode 660
User clamscan
MaxThreads 4

The socket path and the clamscan user can vary slightly between package builds, so read what your file already contains and only change what you need. If you want other users or services, such as a mail filter, to talk to the daemon, add them to a dedicated group and set LocalSocketGroup to match. Do not set the socket mode to 666. That is the lazy fix, and it lets any local account use your scanner as a file-reading oracle.

Enable and start it:

sudo systemctl enable --now clamd@scan.service
sudo systemctl status clamd@scan.service

The first start is slow, often 20 to 60 seconds, because it loads and compiles the signature database. Systemd may show activating for a while. That is normal, not a hang.

Test the daemon with the client:

clamdscan --version
clamdscan -i /home

clamdscan is far faster than clamscan for repeated work. One quirk to know: the daemon scans as the clamscan user, so it must be able to read the files you point it at. If you scan someone’s home directory and get permission errors, that is why. The --fdpass option can help, because it passes an open file descriptor to the daemon instead of making the daemon open the path itself:

clamdscan --fdpass -i /home

Step 5: Schedule Automatic Scans

Manual scans are fine for testing. In production, schedule them. Systemd timers are the modern approach on Fedora and give you better logging than classic cron.

Create a service unit:

sudo nano /etc/systemd/system/clamav-weekly-scan.service
[Unit]
Description=Weekly ClamAV scan
After=clamd@scan.service

[Service]
Type=oneshot
Nice=15
IOSchedulingClass=idle
ExecStart=/usr/bin/clamdscan --fdpass -i --log=/var/log/clamav-weekly.log /srv /home /var/www

And a matching timer:

sudo nano /etc/systemd/system/clamav-weekly-scan.timer
[Unit]
Description=Run ClamAV scan weekly

[Timer]
OnCalendar=Sun *-*-* 03:00:00
Persistent=true
RandomizedDelaySec=30min

[Install]
WantedBy=timers.target

Enable it:

sudo systemctl daemon-reload
sudo systemctl enable --now clamav-weekly-scan.timer
systemctl list-timers | grep clamav

Three details are worth explaining. Nice=15 and IOSchedulingClass=idle keep the scan from competing with real workloads. Persistent=true runs a missed scan after the machine boots, which matters on laptops and on VMs that are powered down at night. RandomizedDelaySec helps if you manage a fleet, so fifty servers do not all hit shared storage at exactly 03:00.

Note that clamdscan exits with code 1 when it finds something. Systemd will mark the unit failed in that case. That is actually useful, since failed units are easy to alert on.

Step 6: Get Alerted When Something Is Found

A scan that finds malware and tells nobody is worthless. The simplest approach is a wrapper script that mails or logs a summary.

sudo nano /usr/local/bin/clamav-report.sh
#!/bin/bash
LOG=/var/log/clamav-weekly.log
if grep -q "FOUND" "$LOG"; then
    logger -p auth.alert -t clamav "Infected files detected, see $LOG"
fi
sudo chmod 750 /usr/local/bin/clamav-report.sh

Then add ExecStartPost=-/usr/local/bin/clamav-report.sh to the service unit. Writing to the journal at alert priority means your existing log shipper, whether that is Loki, Graylog, or a plain syslog forwarder, picks it up without extra plumbing.

Avoid auto-deleting detections with --remove on production data. False positives happen, and deleting a business-critical file at 3 AM is a bad way to learn that. Prefer moving to quarantine:

sudo mkdir -p /var/quarantine
sudo chmod 700 /var/quarantine
clamdscan --fdpass -i --move=/var/quarantine /srv/uploads

The --move option works with clamscan and, with --fdpass, with clamdscan as well. The destination must be writable by the user performing the scan.

SELinux: Do Not Turn It Off

Sooner or later, a scan of some directory fails with permission denied even though the file permissions look correct. The cause is almost always SELinux.

Check for recent denials:

sudo ausearch -m avc -ts recent | tail -20

Fedora’s SELinux policy includes booleans for antivirus software. The one you will most often want lets the scanner read the whole filesystem:

getsebool -a | grep antivirus
sudo setsebool -P antivirus_can_scan_system 1

The -P flag makes it persistent. Without it, the setting vanishes at reboot, which makes for a confusing Monday morning.

If denials persist after that, read the audit message rather than reaching for setenforce 0. Disabling SELinux to make an antivirus work defeats the purpose of running a security tool. Use audit2why to understand the denial, and only generate a custom module as a last resort.

Troubleshooting Common Errors

“ERROR: /etc/freshclam.conf: Please edit the example config file”

The Example line is still active. Comment it out in /etc/freshclam.conf, or in the clamd case, in /etc/clamd.d/scan.conf.

“LibClam Error: cl_load(): No such file or directory”

ClamAV cannot find a signature database. Run sudo freshclam and confirm files exist:

ls -lh /var/lib/clamav/

“ERROR: Can’t open file or directory” / “Can’t connect to clamd”

The daemon is not running, or the socket path is wrong. Check both:

systemctl status clamd@scan.service
ls -l /run/clamd.scan/
grep -i LocalSocket /etc/clamd.d/scan.conf

If clamdscan is looking at a different socket than the one the daemon created, point it at the right config:

clamdscan -c /etc/clamd.d/scan.conf /tmp

clamd@scan fails right after start

Read the journal rather than guessing:

journalctl -u clamd@scan.service -b --no-pager | tail -50

The common causes are the Example line, a missing database, a typo in the config, or an out-of-memory kill.

“freshclam: Failed to lock” or “Locked by another process”

Another FreshClam process is running, usually the systemd service. Stop it, run your manual update, restart the service:

sudo systemctl stop clamav-freshclam.service
sudo freshclam
sudo systemctl start clamav-freshclam.service

FreshClam returns HTTP 429 or “cool-down”

You have been rate limited, usually from checking too often or from many hosts behind a single IP. Lower the frequency, use a private mirror, and wait. Retrying in a tight loop only extends the block.

“WARNING: Your ClamAV installation is OUTDATED”

The installed engine is old enough that upstream wants you to update. Run sudo dnf upgrade --refresh clamav clamav-freshclam clamd. If you are already current in Fedora’s repositories, the warning is usually informational, since the repository build may trail the latest upstream release.

Scans are extremely slow

Check whether you are using clamscan where clamdscan would do, whether large exclusions are missing, and whether the machine is swapping:

vmstat 2 5
iostat -x 2 3

iostat comes from the sysstat package. High %util with low CPU means you are disk bound. High swap activity means the signature set does not fit comfortably in RAM.

Permission denied on specific directories

First check Unix permissions, then SELinux, in that order. Verify the scanning user can traverse the path:

sudo -u clamscan ls /path/to/dir

If that works but scans still fail, return to the antivirus_can_scan_system boolean above and check ausearch output.

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.

Related Posts