OpenSUSE Leap 42: Virus scan with ClamAV

This article will describe virus scan with ClamAV.

1 Virus scan with clamscan

Install clamav and clamav-database package.

> sudo zypper -n in clamav clamav-database

The clamscan command will scan file or directory.

  • -r option will scan directory recursively.
  • -i option will show detected file only.
  • –move option will move detected file to specific directory.
> mkdir ~/virus
> clamscan -r -i --move=$HOME/virus .

2 Update virus database manually

The freshclam command will update virus database. The freshclam command includes in clamav package.

> sudo freshclam

3 Update virus database manually

Enablinng freshclam.service will run daemon which runs freshclam command 12 times in a day.

> sudo systemctl enable freshclam
> sudo systemctl start freshclam

For changing update interval, you need to modify the following file.

> grep Checks /etc/freshclam.conf
#Checks 24

4 Virus scan with clamd

The clamd daemon load database once and wait as a daemon. And run virus scan by request from clamdscan command without loading database.

clamd daemon always consume memory for database, but clamdscan is faster than clamscan. And clamdscan's behavior depends on clamd while clamscan's behavior depends clamscan's options.

Change running clamd user to root.

> sudo sed -e 's/^User.*/User root/g' -i /etc/clamd.conf

Enable clamd.service.

> sudo systemctl enable clamd
> sudo systemctl start clamd

You can run clamdscan.

> clamdscan <file-or-dir>

5 Virus scan with clamtk package

clamtk package provides GUI window, This is useful for desktop user.

> S=http://download.opensuse.org/repositories/security/openSUSE_Leap_42.2
> sudo zypper ar -f -n Security ${S} Security
> sudo zypper -n --gpg-auto-import-keys ref
> sudo zypper -n in clamtk

clamtk is as the following. My environment needs double click to select item.

0001_ClamTk.png

Check "scan directories recursively" in Settings.

0002_ScanDirectoriesRecursively.png

Home directory can be scanned recursively by "Scan a directory".

0003_ScanADirectory.png