Difference between revisions of "ClamAV"

From ArchWiki
Jump to: navigation, search
m (Don't use -Sy)
(Updating database)
(27 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[[Category: Security (English)]]
+
[[Category:Daemons and system services]]
{{i18n_links_start}}
+
[[Category:Security]]
{{i18n_entry|English|ClamAV}}
+
[[es:ClamAV]]
{{i18n_entry|Español|Cómo instalar y configurar ClamAV Antivirus}}
+
[[it:ClamAV]]
{{i18n_links_end}}
+
[[ru:ClamAV]]
 
+
[[sr:ClamAV]]
 +
[[zh-CN:ClamAV]]
 
[http://www.clamav.net 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.
 
[http://www.clamav.net 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.
  
==Installation==
+
== Installation ==
Install with pacman by:
+
ClamAV can be [[pacman|installed]] with package {{Pkg|clamav}}, available in the [[Official Repositories]].
# pacman -S clamav
+
  
==Configuration==
+
== Configuration ==
Whether you are going to use clamav as a daemon or use it as a simple file checker you need to comment out ''Example'' in the {{Filename|/etc/clamav/freshclam.conf}} file(you probably need to do the same to {{Filename|clamd.conf}} in the same dir too) and update the virus & malware database.
+
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 {{ic|/etc/clamav/freshclam.conf}} and {{ic|/etc/clamav/clamd.conf}} files.
  
==Update Database==
+
== Starting the daemon ==
The daemon needs to be running for the virus update to be updated:
+
If you want to use the daemon, you can start it with:
  # /etc/rc.d/clamav start
+
  # rc.d start clamav
  
Then update the virus definitions with:
+
To start it automatically at boot add '''clamav''' to the {{Ic|DAEMONS}} array in {{ic|/etc/rc.conf}}. Also in {{ic|/etc/conf.d/clamav}} change the start options from "no" to "yes".
 +
 
 +
# change these to "yes" to start
 +
START_FRESHCLAM="yes"
 +
START_CLAMD="yes"
 +
 
 +
If you want to use the daemon in a systemd environment:
 +
# systemctl enable clamd
 +
 
 +
== Updating database ==
 +
Edit the below file and comment out the line saying "Example"
 +
# vim /etc/clamav/freshclam.conf
 +
  # Comment or remove the line below.
 +
  #Example
 +
 
 +
Update the virus definitions with:
 
  # freshclam
 
  # freshclam
  
Line 25: Line 40:
 
  /var/lib/clamav/main.cvd
 
  /var/lib/clamav/main.cvd
  
==Server setup==
+
== Scan for Viruses ==
To run as a server edit {{Filename|/etc/clamav/clamd.conf}} and {{Filename|/etc/clamav/freshclam.conf}} and comment out the ''Example'' flag.  In {{Filename|/etc/conf.d/clamav}} change the start options from "no" to "yes".
+
{{ic|clamscan}} can be used to scan certain files, home directory, or an entire system:
 
+
# change these to "yes" to start
+
START_FRESHCLAM="yes"
+
START_CLAMD="yes"
+
 
+
* To start clamav at boot edit {{Filename|/etc/rc.conf}} and add clamav.
+
==Scan for Viruses==
+
{{Codeline|clamscan}} can be used to scan certain files, home directory, or an entire system:
+
  
 
  $ clamscan myfile
 
  $ clamscan myfile
Line 40: Line 47:
 
  $ clamscan -r -i --exclude-dir=^/sys\|^/proc\|^/dev /
 
  $ clamscan -r -i --exclude-dir=^/sys\|^/proc\|^/dev /
  
If you'd like {{Codeline|clamscan}} to remove the infected file use the {{Codeline|--remove}} option in the command.
+
If you would like {{ic|clamscan}} to remove the infected file use the {{ic|--remove}} option in the command.
  
==Troubleshooting==
+
== Troubleshooting ==
 
If you get the following messages after running freshclam:
 
If you get the following messages after running freshclam:
  WARNING: Clamd was NOT notified: Can't connect to clamd through  
+
  WARNING: Clamd was NOT notified: Cannot connect to clamd through  
 
  /var/lib/clamav/clamd.sock connect(): No such file or directory
 
  /var/lib/clamav/clamd.sock connect(): No such file or directory
  
Line 50: Line 57:
 
  # touch /var/lib/clamav/clamd.sock
 
  # touch /var/lib/clamav/clamd.sock
 
  # chown clamav:clamav /var/lib/clamav/clamd.sock
 
  # chown clamav:clamav /var/lib/clamav/clamd.sock
 +
Then, edit {{Ic|/etc/clamav/clamd.conf}} – uncomment this line:
 +
LocalSocket /var/lib/clamav/clamd.sock
 +
Save the file and restart the daemon (rc.d stop clamav; rc.d start clamav)
  
 
If you get the next error when starting the daemon:
 
If you get the next error when starting the daemon:
Line 57: Line 67:
 
Run freshclam as root:
 
Run freshclam as root:
 
  # freshclam -v
 
  # freshclam -v
 +
 +
If you get a:
 +
# can't create temporary directory
 +
error,
 +
along with a 'HINT' containing a UID and a GID number.
 +
 +
Do the following:
 +
# chown UID:GID /var/lib/clamav & chmod 755 /var/lib/clamav
 +
 +
# ex: chown 64:64

Revision as of 01:52, 19 November 2012

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.

Installation

ClamAV can be installed with package clamav, available in the Official Repositories.

Configuration

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/clamav/freshclam.conf and /etc/clamav/clamd.conf files.

Starting the daemon

If you want to use the daemon, you can start it with:

# rc.d start clamav

To start it automatically at boot add clamav to the DAEMONS array in /etc/rc.conf. Also in /etc/conf.d/clamav change the start options from "no" to "yes".

# change these to "yes" to start
START_FRESHCLAM="yes"
START_CLAMD="yes"

If you want to use the daemon in a systemd environment:

# systemctl enable clamd

Updating database

Edit the below file and comment out the line saying "Example"

# vim /etc/clamav/freshclam.conf
  # Comment or remove the line below.
  #Example

Update the virus definitions with:

# freshclam

The database files are saved in:

/var/lib/clamav/daily.cvd
/var/lib/clamav/main.cvd

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 /

If you would like clamscan to remove the infected file use the --remove option in the command.

Troubleshooting

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

Then, edit /etc/clamav/clamd.conf – uncomment this line:

LocalSocket /var/lib/clamav/clamd.sock

Save the file and restart the daemon (rc.d stop clamav; rc.d start clamav)

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

Run freshclam as root:

# freshclam -v

If you get a:

# can't create temporary directory

error, along with a 'HINT' containing a UID and a GID number.

Do the following:

# chown UID:GID /var/lib/clamav & chmod 755 /var/lib/clamav 
# ex: chown 64:64