Why
While Linux is less susceptible to viruses than other operating systems, it’s not immune. ClamAV helps detect viruses, malware, and malicious files that could harm your system or be transmitted to other systems.How It Works
ClamAV consists of several components:- ClamAV - The virus scanner itself
- ClamAV-Freshclam - A service that keeps virus definitions updated automatically
- ClamAV-Daemon - Keeps the
clamdprocess running to make scanning faster
Goals
- ClamAV installed and configured for manual or scheduled virus scanning
- Automatic virus definition updates
Notes
- These instructions do not configure the ClamAV daemon service for real-time monitoring
- The
clamddaemon is primarily useful if you’re running a mail server - For most servers, scanning files manually or on a schedule is sufficient
- ClamAV does not provide real-time file monitoring
References
- https://www.clamav.net/documents/installation-on-debian-and-ubuntu-linux-distributions
- https://wiki.debian.org/ClamAV
- https://www.osradar.com/install-clamav-debian-9-ubuntu-18/
- https://www.lisenet.com/2014/automate-clamav-to-perform-daily-system-scan-and-send-email-notifications-on-linux/
- https://www.howtoforge.com/tutorial/configure-clamav-to-scan-and-notify-virus-and-malware/
Installation and Setup
Configure freshclam
Make a backup of The default settings are probably sufficient, but you can customize them by editing
clamav-freshclam’s configuration file:/etc/clamav/freshclam.conf or using:The default settings update virus definitions 24 times per day. To change the interval, check the
Checks setting in /etc/clamav/freshclam.conf.Start the freshclam service
Start the automatic virus definition updater:Verify it’s running:You should see it downloading virus definition databases.
Scanning Files and Folders
Using clamscan
To scan files and folders, use theclamscan program:
Common Options
| Option | Description |
|---|---|
-r | Scan directories recursively |
-i | Only print infected files |
-l FILE | Save scan report to FILE |
--remove | Remove infected files |
--move=DIRECTORY | Move infected files to DIRECTORY |