How to scan your server for malware with ClamAV
Updated 10/16/2026
ClamAV is an open-source antivirus used to scan servers, especially those receiving files from users (uploads, email attachments).
1. Install
apt-get update -y
apt-get install -y clamav clamav-daemon
2. Update the signature database
systemctl stop clamav-freshclam
freshclam
systemctl start clamav-freshclam
3. Scan a directory
clamscan -r --infected /var/www
The -r option scans recursively, --infected shows only problematic files.
4. Schedule automatic scans
Add a daily scan to cron that quarantines infected files:
0 2 * * * clamscan -r --move=/var/quarantine /var/www
Tip
Scanning uses a lot of RAM and CPU. Run it at night, during low-traffic hours. Combine with regular backups, see the backup guides, so you can restore clean if you find an infection.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
How to check which ports are open on your server
Find out which services are listening for connections on your server and close what you do not need, for less exposure.
Updated 10/16/2026SecurityHow to set up your own VPN with WireGuard
Run your own private, fast and secure VPN with WireGuard on a VPS, for private browsing and secure access.
Updated 10/16/2026SecurityHow to add security headers to your website
A few HTTP headers protect your visitors from common attacks like clickjacking and content injection.
Updated 10/16/2026