How To Install ClamAV on Ubuntu 26.04 LTS

Install ClamAV on Ubuntu 26.04

A Linux server can go for months without a visible problem and still be passing infected files along. A WordPress upload folder, a Samba share that Windows laptops write to, or a mail spool can each hold a payload that never harms the host. Those files harm everyone who downloads them later. That is why antivirus on Linux is not a joke. The target is usually not the server itself. It is the people and systems that trust what the server hands out.

ClamAV is the standard answer. It is open source, maintained by Cisco Talos, and light enough to run on a small VPS. It also plugs into mail gateways, web upload handlers, file shares and cron jobs without much ceremony. It does have rough edges. The signature database is large, the default daemon settings are conservative, and a fresh install can leave you with a daemon that refuses to start for reasons the logs describe poorly.

Ubuntu 26.04 LTS “Resolute Raccoon” was released on April 23, 2026, and will get standard security support until April 2031. That makes it a sensible base for a ClamAV deployment you intend to keep for years. This guide covers the whole path: installing the packages, getting signatures updated, starting the daemon, scanning on a schedule, watching directories in real time, tuning for production, and fixing the failures that waste an afternoon.

What You Are Installing (and What Version to Expect)

Ubuntu splits ClamAV into several packages, and it helps to know which does what before you run apt install.

  • clamav provides the command-line scanner clamscan and supporting tools.
  • clamav-daemon provides clamd, the long-running scanning service, plus clamdscan, a thin client that talks to it.
  • clamav-freshclam provides the signature updater, run as a systemd service.

The package page for 26.04 shows the release pocket carrying ClamAV 1.5.4 (1.5.4+dfsg-0ubuntu0.26.04.1, published September 21, 2026). Upstream already shipped 1.5.5 as a patch release on November 18, 2026, so expect Ubuntu to pick it up through updates in due course. Check what your own mirror serves with apt policy clamav.

The 1.5 branch brought a change worth knowing about. It added a FIPS-compatible way of verifying signature database archives, using .cvd.sign files for the daily, main and bytecode databases. If those files are missing, ClamAV falls back to the older MD5-based RSA check. You will not need to configure anything, but it explains the extra files you may see in the database directory.

One more point on versions. Upstream documentation has described 1.4 as the long-term support release and 1.5 as the newest feature line. Distribution packages follow their own rules, so judge by the Ubuntu security tracker, not the upstream label. Very old clients are also blocked from signature updates. Versions 0.105 and older cannot download them at all, so an unpatched legacy box is effectively blind.

Prerequisites Before You Touch the Terminal

A few minutes of preparation prevents most of the failures covered later.

Memory. This is the one that bites. ClamAV loads its entire signature set into RAM when clamd starts. Plan for roughly 1.5 GB free on a quiet system, and more when databases reload, because the default behavior builds the new database beside the old one before swapping. A 1 GB VPS will struggle with the daemon. It can still run clamscan on demand, though each run takes a while to load signatures.

Disk. The signature databases take a few hundred megabytes under /var/lib/clamav. Add room for logs and any quarantine directory.

Network. The updater needs outbound HTTPS to database.clamav.net. Locked-down egress firewalls are a classic reason updates fail silently.

Access. You need a sudo-capable account. Check the release and kernel first:

lsb_release -ds
uname -r
free -h
df -h /var

Sizing note from experience: on a 2 GB web server running PHP-FPM and MariaDB, the daemon fits, but only after MariaDB’s buffer pool and PHP’s worker count have been sized with it in mind. Adding ClamAV last, without checking, is how an out-of-memory kill takes down your database instead of your scanner.

Step 1: Update the System and Install the Packages

Refresh the package index and apply pending upgrades. Installing security software on a stale system is asking for dependency trouble.

sudo apt update
sudo apt upgrade -y

Now install the scanner, the daemon and the updater together:

sudo apt install -y clamav clamav-daemon

The clamav-freshclam package comes along as a dependency, and clamdscan is pulled in as a recommended package. If you run apt with recommends disabled, install it explicitly:

sudo apt install -y clamav clamav-daemon clamdscan

Confirm what landed:

clamscan --version
apt policy clamav clamav-daemon

The version output prints the engine version, the signature database version, and a date. A signature date several days old means updates are failing. Keep that habit, because it is the quickest health check ClamAV offers.

Step 2: Get the Signature Database Updating

This step trips up more first-time installs than any other. Right after installation, freshclam runs as a background service and starts downloading the databases. The clamd service will not start until at least the main databases exist, because it has nothing to load.

Check the updater:

systemctl status clamav-freshclam --no-pager
sudo journalctl -u clamav-freshclam -n 50 --no-pager

If you want to watch the first download interactively, stop the service and run the updater by hand:

sudo systemctl stop clamav-freshclam
sudo freshclam
sudo systemctl start clamav-freshclam

You should see main.cvd, daily.cvd (or daily.cld), and bytecode.cvd being fetched. Verify they exist:

ls -lh /var/lib/clamav/

Running freshclam manually while the service is active produces a lock error, so always stop the service first. The same stop, run, start pattern is what you reach for when updates have stalled.

Tuning the update schedule

The configuration lives in /etc/clamav/freshclam.conf. The defaults are sensible, and the most relevant lines look like this:

DatabaseOwner clamav
UpdateLogFile /var/log/clamav/freshclam.log
LogVerbose false
LogSyslog false
Checks 24
DatabaseMirror database.clamav.net

Checks 24 means 24 update checks per day, which is hourly. That is fine. Raising it further is pointless and can get you rate-limited by the content delivery network. If you run a fleet, mirror the databases internally (see the production section) instead of having fifty servers hit the public endpoint.

For servers behind a proxy, add:

HTTPProxyServer proxy.example.internal
HTTPProxyPort 3128

Restart after changes:

sudo systemctl restart clamav-freshclam

Step 3: Start and Verify the ClamAV Daemon

With signatures in place, enable the daemon:

sudo systemctl enable --now clamav-daemon
systemctl status clamav-daemon --no-pager

Do not panic if it takes a while. On a modest CPU, loading the full signature set can take from half a minute to a couple of minutes, and during that time systemd may report the service as still activating. Watch it:

sudo journalctl -u clamav-daemon -f

You are waiting for lines that report the engine is ready and the socket is listening. Ubuntu’s default socket is a Unix socket at /var/run/clamav/clamd.ctl. Check it exists and ping the daemon:

ls -l /var/run/clamav/clamd.ctl
clamdscan --ping 5

Another health check that sysadmins often forget is the STATS command, which shows queue depth and memory use. Version 1.5.0 fixed a bug that broke memory reporting on Linux, so it is trustworthy on current builds:

echo STATS | sudo nc -U /var/run/clamav/clamd.ctl

If you do not have a netcat build with Unix socket support, apt install netcat-openbsd fixes that.

Step 4: Prove It Works with the EICAR Test File

Never assume a scanner works. Test it. The EICAR string is a harmless, industry-standard test pattern that every antivirus engine flags on purpose. Create it safely in a temp directory:

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

Scan with both the standalone scanner and the daemon client:

clamscan /tmp/avtest/eicar.txt
clamdscan /tmp/avtest/eicar.txt

Both should report Eicar-Signature FOUND (the exact label can vary slightly between databases). If clamscan finds it but clamdscan does not, the daemon is the problem, usually a permissions issue with the target path. That scenario is covered under troubleshooting.

Clean up afterward:

rm -rf /tmp/avtest

clamscan vs clamdscan: Which One Should You Use?

This is worth understanding, because choosing wrong hurts performance.

Aspect clamscan clamdscan
Loads signatures Every run Once, kept by daemon
Startup time Slow (many seconds) Near instant
RAM use Spikes per run Constant, always resident
Runs as Calling user The clamav user
Best for Occasional full scans, small servers Frequent scans, uploads, mail
Multithreaded No Yes (via MaxThreads)

clamdscan is a client for the clamd daemon, which keeps signatures loaded, so scans start at once. The guidance is to use clamscan for occasional scans on small servers and clamd with clamdscan for frequent scans such as uploads or mail.

A practical rule: if a scan happens more than a few times an hour, use the daemon. If it happens nightly, clamscan is simpler and frees the memory the rest of the day.

One catch catches people out. clamdscan hands the path to the daemon, and the daemon reads the file as the clamav user. If that user cannot read the file, the scan fails or skips it. Using --fdpass passes an open file descriptor instead, which sidesteps the issue:

clamdscan --fdpass --multiscan /srv/www

--multiscan spreads the work across the daemon’s threads, which matters on multi-core hosts.

Step 5: Run Your First Real Scan

For a manual scan of a directory tree, listing only infected files:

sudo clamscan -r -i /home /srv

The -r flag recurses, and -i suppresses the clean file noise. Useful additions:

sudo clamscan -r -i --exclude-dir="^/proc" --exclude-dir="^/sys" --exclude-dir="^/dev" / -l /var/log/clamav/fullscan.log

Scanning / blindly is rarely smart. Pseudo-filesystems like /proc and /sys are not real files, and scanning them wastes time and can throw errors. Use --one-file-system to stay off mounted network shares and bind mounts:

sudo clamscan -r -i --one-file-system /

Want to move detections out of the way instead of only listing them? Create a quarantine directory with tight permissions and use --move:

sudo mkdir -p /var/quarantine
sudo chown root:root /var/quarantine
sudo chmod 700 /var/quarantine
sudo clamscan -r -i --move=/var/quarantine /srv/uploads

Resist the urge to use --remove on production data. A false positive on a customer’s file that you have already deleted is a conversation nobody enjoys. Quarantine first, review, then delete.

Step 6: Automate Scans with a systemd Timer

Cron works, and plenty of production boxes still use it. A systemd timer is cleaner, though, because logging, resource limits and failure state all live in one place.

Create the service unit:

sudo nano /etc/systemd/system/clamav-nightly.service
[Unit]
Description=Nightly ClamAV scan of web and upload directories
After=clamav-daemon.service
Requires=clamav-daemon.service

[Service]
Type=oneshot
Nice=15
IOSchedulingClass=idle
CPUQuota=50%
ExecStart=/usr/bin/clamdscan --fdpass --multiscan --infected --log=/var/log/clamav/nightly.log /srv/www /home
SuccessExitStatus=0 1

Now the timer:

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

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

[Install]
WantedBy=timers.target

Enable it:

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

A few notes on why this is written the way it is. Nice and IOSchedulingClass=idle keep the scan from fighting your web server for disk. CPUQuota=50% caps it so a scan during a traffic spike does not starve PHP. RandomizedDelaySec matters if you manage many servers on shared storage, since it avoids every machine hammering the SAN at 03:30 sharp. SuccessExitStatus=0 1 treats exit code 1 (virus found) as a completed job instead of a service failure, which keeps monitoring noise down while you still read the log.

Get alerts without installing a mail stack by logging to a file and pushing summaries into your existing monitoring, whether that is Prometheus textfile exporter, Zabbix, or a simple script posting to a chat webhook.

Step 7: Real-Time Protection with On-Access Scanning

Scheduled scans catch yesterday’s problem. On-access scanning, handled by clamonacc, checks files as they are opened or written. It uses the kernel’s fanotify interface. It suits upload landing zones and shared directories better than whole-filesystem protection.

Edit the daemon config:

sudo nano /etc/clamav/clamd.conf

Add:

OnAccessIncludePath /srv/uploads
OnAccessExcludeUname clamav
OnAccessPrevention no
OnAccessExtraScanning yes
OnAccessMountPath /srv

Choose either OnAccessIncludePath or OnAccessMountPath as your watch strategy, not both indiscriminately. Mixing them in a way that overlaps leads to duplicate events. OnAccessExcludeUname clamav is essential, because without it the daemon scanning a file triggers a new on-access event, which triggers another scan, and so on.

Set OnAccessPrevention yes only after thorough testing. In prevention mode, file access is blocked until the scan finishes. If the daemon hangs or restarts, applications reading those files hang too. Starting in detect-only mode (no) is the safer way to learn what your traffic looks like.

Run the on-access client:

sudo clamonacc --fdpass --log=/var/log/clamav/clamonacc.log

For persistence, wrap it in a unit file:

[Unit]
Description=ClamAV On-Access Scanner
Requires=clamav-daemon.service
After=clamav-daemon.service

[Service]
Type=simple
ExecStart=/usr/sbin/clamonacc -F --fdpass --log=/var/log/clamav/clamonacc.log
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save it as /etc/systemd/system/clamonacc.service, then reload and enable it. Many distributions ship a clamav-clamonacc unit, so check systemctl list-unit-files | grep clamonacc before writing your own.

Test by dropping the EICAR file into the watched directory and confirming the log records it.

Troubleshooting Common ClamAV Errors

This is where most real time gets spent. These are the failures that show up repeatedly.

clamd fails to start: “Can’t open/parse the config file”

A typo or stray character in clamd.conf. Validate:

sudo clamconf -n
sudo -u clamav clamd --config-file=/etc/clamav/clamd.conf --foreground --debug 2>&1 | head -50

Fix the line named in the error, then restart.

clamd fails with “Can’t open file or directory” for the database

The databases are missing because freshclam has not finished or failed. Check /var/lib/clamav/, run the manual update from Step 2, then start the daemon.

“Failed to lock the log file” or lock errors in freshclam

Two updaters are running at once. Stop the service before a manual run:

sudo systemctl stop clamav-freshclam
sudo freshclam
sudo systemctl start clamav-freshclam

“Can’t connect to clamd through /var/run/clamav/clamd.ctl”

Either the daemon is still loading signatures, it crashed, or the socket path differs. Check:

systemctl status clamav-daemon --no-pager
grep -i LocalSocket /etc/clamav/clamd.conf
ls -l /var/run/clamav/

Give it time. Large databases take a while to load after boot, and clients that fire immediately will see this error.

“Permission denied” when clamdscan scans files

The clamav user cannot read the target. Use --fdpass, or grant read access via group membership. A common pattern is adding clamav to the web group:

sudo usermod -aG www-data clamav
sudo systemctl restart clamav-daemon

Group changes need a service restart to take effect.

freshclam: “Can’t download daily.cvd” or connection failures

Test reachability and DNS:

curl -I https://database.clamav.net
sudo freshclam --verbose

Check egress firewalls, proxy settings, and system time. Badly skewed clocks cause TLS failures. If you are on an old ClamAV release that upstream has blocked, upgrade the package. Occasionally the CDN rate-limits a host that checks too often, so do not raise Checks above the default.

Daemon killed randomly (OOM)

Look at the kernel log:

sudo dmesg -T | grep -i -E "killed process|out of memory"
sudo journalctl -k | grep -i oom

If clamd is the victim around the top of the hour, the database reload is the cause. Set ConcurrentDatabaseReload no, add swap as a safety net, or move to a larger instance.

High CPU during scans

Expected, but tameable. Lower MaxThreads, add CPUQuota in the service unit, or schedule scans for off-peak. Avoid scanning compressed backup archives repeatedly, since decompression is expensive.

On-access scanning does nothing

clamonacc needs a kernel with fanotify support and must run as root. Confirm the paths in OnAccessIncludePath exist, that OnAccessExcludeUname clamav is set, and that the daemon is reachable. In containers and some VPS platforms, fanotify is restricted, so on-access may simply be unavailable. Fall back to timers and upload hooks there.

Signature date is old

Run clamscan --version. An old date means updates are broken. Check journalctl -u clamav-freshclam, fix the network or proxy problem, and confirm that a manual freshclam succeeds.

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