zh-CN:ClamAV Clam AntiVirus is an open source (GPL) anti-virus toolkit for UNIX. It provides a number of utilities including a flexible and scalable multi-threaded daemon, a command line scanner and advanced tool for automatic database updates. Because ClamAV's main use is on file/mail servers for Windows desktops it primarily detects Windows viruses and malware.
Whether you are going to use ClamAV as a daemon or use it as a simple file checker you need to comment out the line that contains the word Example, usually it is found at the beginning of
/etc/clamavwill instead contain similar files marked with *.sample extension instead. Modifying these as prescribed above and then writing them out with the files names mentioned above will achieve the same result.
Starting the daemon
The service is called
clamd.service. Read Daemons for more information about starting it and enabling it to start at boot.
Also change the start options from
# change these to "yes" to start START_FRESHCLAM="yes" START_CLAMD="yes"
Edit the below file and comment out the line saying
# Comment or remove the line below. # Example
Update the virus definitions with:
The database files are saved in:
Scan for viruses
clamscan can be used to scan certain files, home directory, or an entire system:
$ clamscan myfile $ clamscan -r -i /home $ clamscan -r -i --exclude-dir='^/sys|^/proc|^/dev|^/lib|^/bin|^/sbin' /
If you would like
clamscan to remove the infected file use the
--remove option in the command.
-l path/to/file option will print the
clamscan logs to a text file for locating reported infections.
Error: Clamd was NOT notified
If you get the following messages after running freshclam:
WARNING: Clamd was NOT notified: Cannot connect to clamd through /var/lib/clamav/clamd.sock connect(): No such file or directory
Add a sock file for ClamAV:
# touch /var/lib/clamav/clamd.sock # chown clamav:clamav /var/lib/clamav/clamd.sock
/etc/clamav/clamd.conf - uncomment this line:
Save the file and restart the daemon
Error: No supported database files found
If you get the next error when starting the daemon:
LibClamAV Error: cli_loaddb(): No supported database files found in /var/lib/clamav ERROR: Not supported data format
Generate the database as root:
# freshclam -v
Error: Can't create temporary directory
If you get the following error, along with a 'HINT' containing a UID and a GID number:
# can't create temporary directory
# chown UID:GID /var/lib/clamav & chmod 755 /var/lib/clamav