Install ClamAV and update signatures
sudo apt update
sudo apt install clamav clamav-daemon
| Component | What it does |
|---|---|
clamscan | Standalone scanner; loads signatures each time it runs (simple but slow to start) |
clamd (clamav-daemon) | Background service that keeps signatures in memory for fast scans |
clamdscan | Client that sends scan jobs to clamd |
freshclam | Downloads signature updates; runs as the clamav-freshclam service |
The freshclam service updates signatures automatically. Check that it is working:
sudo systemctl status clamav-freshclam
sudo tail /var/log/clamav/freshclam.log
If you want to run freshclam by hand and it reports a lock error, stop the service first (sudo systemctl stop clamav-freshclam), run it, then start the service again. The official ClamAV documentation covers configuration in depth.
Plan for memory use
The signature database is large. When clamd loads it, expect it to use roughly 1–1.5 GB of RAM, and briefly more while reloading after an update. On a small VPS, either run occasional clamscan jobs instead of the daemon, or choose a plan with enough memory for both your applications and ClamAV.

Run your first scans
With clamscan
sudo clamscan -r -i /var/www
sudo clamscan -r -i --exclude-dir="^/sys|^/proc|^/dev" /
-r scans recursively and -i prints only infected files. Scanning web roots, upload folders, /tmp, /var/tmp and home directories gives the best return for the time. A full-system scan takes much longer.
With the daemon (faster)
sudo systemctl enable --now clamav-daemon
sudo clamdscan --multiscan --fdpass -i /var/www
--multiscan uses several threads, and --fdpass lets clamd read files it would not otherwise have permission to open.
Moving infected files instead of deleting them
sudo mkdir -p /root/quarantine
sudo clamscan -r -i --move=/root/quarantine /var/www
Quarantining keeps evidence for investigation. Avoid --remove on a live website until you know what the file is: a false positive could break the site, and a real infection needs investigating, not just deleting.
Schedule regular scans
Create /etc/cron.daily/clamav-scan:
#!/bin/sh
LOG=/var/log/clamav/daily-scan.log
clamdscan --multiscan --fdpass -i /var/www /home /tmp > "$LOG" 2>&1
if grep -q "FOUND" "$LOG"; then
mail -s "ClamAV found malware on $(hostname)" admin@example.com < "$LOG"
fi
sudo chmod +x /etc/cron.daily/clamav-scan
The email step needs a working mail setup; replace it with a webhook or your monitoring tool if you prefer. Run the scan at a quiet hour, because scanning large sites uses CPU and disk.
What ClamAV can and cannot do
ClamAV is useful, but it is not a complete security system:
- It finds known malware. Detection relies on signatures, so brand-new or heavily obfuscated web shells may be missed.
- It scans files, not behaviour. A cryptominer running from memory, or an attacker using a stolen password, will not show up in a file scan.
- It does not fix the entry point. If an outdated plugin let malware in, it will come back until the plugin is updated.
Combine it with other layers:
- Linux Malware Detect (maldet), which focuses on web-hosting threats and can use ClamAV's engine.
- rkhunter or chkrootkit to look for rootkits.
- File-integrity monitoring such as AIDE, which alerts when system files change.
- Prompt updates for the OS, CMS, plugins and themes, plus strong SSH settings; see the server hardening guide.
What to do if ClamAV finds malware
- Do not panic-delete. Quarantine the files and note their paths and timestamps.
- Check for a false positive. Look at the file. Some admin tools and minified scripts trigger heuristic signatures.
- Find the entry point. Compare file timestamps with web server access logs to see which request created them.
- Close the hole: update the vulnerable software and change every password the site or server uses, including database passwords; our guide to resetting MySQL passwords helps.
- Look for persistence: unknown cron jobs, new users, new SSH keys and unfamiliar processes. Our VPS troubleshooting guide lists the commands.
- Rebuild if in doubt. If an attacker had root access, restore onto a clean installation from a backup taken before the compromise.
Why developers choose SkyRain Cloud VPS
Security tools need resources to run well. SkyRain Cloud Intel VPS plans give you:
- KVM virtualization. Your own kernel and allocated vCores, so you can tune the system the way this guide describes.
- Intel Xeon Platinum 8269CY hosts. Server-class Cascade Lake CPUs with DDR4 ECC memory.
- NVMe SSD storage on every plan, which keeps I/O wait low for databases and builds.
- Full root access to install and configure whatever your stack needs.
- Unmetered 1 Gbps port in India, close to your users.
- Simple billing and real support. Monthly billing in rupees with UPI, plus 24/7 tickets, WhatsApp and Discord.
Frequently Asked Questions
Is ClamAV free?
How do I scan a folder with ClamAV?
How much RAM does ClamAV need?
Does ClamAV detect PHP web shells?
How do I update ClamAV virus definitions?
Should I delete infected files automatically?
Conclusion
ClamAV gives you a free, scriptable way to check a Linux server for known malware. Install it, let freshclam keep signatures current, scan web roots and temporary folders on a schedule, and quarantine rather than delete. Treat it as one layer: keeping software updated and access locked down prevents most infections in the first place.
For a VPS with root access and room for security tools, see our Intel VPS plans.
SkyRain Cloud Intel Xeon VPS Plans
KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — Intel | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Business websites, small apps, scheduled jobs and bots | Order |
| VPS 2 — Intel | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,169/month | Business software, mid-size databases, several sites on one server | Check stock |
| VPS 3 — Intel | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,249/month | ERP/CRM stacks, heavier databases, multiple production apps | Check stock |
| VPS 4 — Intel | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,299/month | High-memory workloads and consolidated production servers | Check stock |
Prices are monthly in INR as listed on the SkyRain Cloud store (verified 2026-11-23). Live stock and final price are shown at checkout.