User Tools

Site Tools


clamav

Anti virus on Linux

The general consensus is that anti virus is rarely needed on a Linux home computer:

  • All applications are downloaded through trusted sources
  • Windows is the larger more common target

However, you can also argue:

  • Downloaded documents can also contain malware
  • Linux is more common on servers, malware does exist

ClamAV

There are not many free and reliable anti viruses. In fact, the only one I know is ClamAV which is an Open Source AV by Cisco Inc.

Search your repository for clamav (apt, dnf or if you use Bazzite: brew)

It's all command line interface, but there is also a user interface in Flathub: ClamTk

What to scan

Scanning the entire computer is overkill, especially on atomic distros like Bazzite.

Here is a setup that works for me, which will scan new files in the Downloads-folder.

  1. Create a file called scandownload.sh somewhere nice
  2. Add the contents described below
  3. Make it executable with chmod +x scandownload.sh
  4. Search KDE settings for Autostart and add it as a login script

The contents of the script is:

#!/bin/bash
 
#Check for updates
freshclam > /dev/null

#Folder to check
DIR=$HOME/Downloads
 
# Get rid of old log file
rm $HOME/virus-scan.log 2> /dev/null
 
inotifywait -q -m -e close_write,moved_to --format '%w%f' $DIR | while read FILE
do
     # Have to check file length is nonzero otherwise commands may be repeated
     if [ -s $FILE ]; then
          #scan the file and save the log
          clamscan $FILE > $HOME/virus-scan.log

          #check if the log contains text if the scan was OK          
          isok=$(grep -c ': OK' $HOME/virus-scan.log)

          #if it was not OK, show a dialog to warn the user
          if ! [ $isok ]; then
               kdialog --title "Download scan" --msgbox "Virus found!" "$(cat "$HOME/virus-scan.log")"
          fi
     fi
done

Credit to Fitzcarraldo

clamav.txt · Last modified: by mathog

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki