×

Although it is said that malware that infects Linux is not very common, it is still a very good idea to install anti-malware protection software on your Linux machine. If you transfer files between machines or exchange files with other computer users, you may want to scan such files for viruses and other forms of malware.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Software Installation tasks on their Linux Servers.

In this context, we shall look into how to install ClamAV — an open-source anti-malware protection software developed by Cisco Systems on Ubuntu.

Also, we will install a graphical tool for using ClamAV called ClamTK.


How to install ClamAV on Ubuntu ?

To begin, run the following command to update the list of packages on Ubuntu if you have not done so in a while:

$ sudo apt-get update

Run the next command to begin installing ClamAV:

$ sudo apt-get install clamav

If prompted, enter y to continue installing ClamAV.


How to Download the Latest ClamAV Virus Database on Ubuntu ?

ClamAV uses a frequently updated database of known viruses. The database files are stored in /var/lib/clamav by default.

i. First, run the command below to stop the ClamAV database updater service so that the necessary files can be successfully accessed:

$ sudo systemctl stop clamav-freshclam

ii. Next, download the latest ClamAV virus database by running the following command:

$ sudo freshclam

iii. You may now start the ClamAV database updater by running the command below:

$ sudo systemctl start clamav-freshclam

iv. To ensure that the ClamAV database updater service is always started whenever the system boots, run the next command:

$ sudo systemctl enable clamav-freshclam


How to Perform a Manual Scan with clamscan on Ubuntu ?

For your basic scanning tasks, ClamAV includes a command-line tool called clamscan.

The basic usage of the clamscan command is:

$ clamscan [options] [file or directory path to scan]

To see all available clamscan options, run:

$ man clamscan

Some common options for using clamscan include:

–log=file – to save the scan report to the specified file

–bell – to sound a bell when a virus is detected

–recursive – to scan all subfolders within the specified directory

–max-filesize=xm – to skip files larger than xm, where x is a number and m means megabytes


For example, the following command scans everything in my home directory:

$ clamscan -r /home/linuxapt


How to Schedule a Daily Scan with clamscan on Ubuntu ?

In order to schedule a daily scan, you could create a small script in /etc/cron/cron.daily containing the clamscan instructions.

i. Run the following command to create the script file.

$ sudo nano /etc/cron.daily/clamscan_daily

As an example, the script below will recursively scan my Downloads folder. 

ii. You may copy this script but remember to edit the folder path to scan on the second line.

#!/usr/bin/env bash
clamscan -r /home/shola/Downloads

iii. Save changes and close the file.

iv. Next, run the command below to make the script file executable.

$ chmod +x /etc/cron.daily/clamscan_daily

The script will automatically run once a day.


How to Install ClamTK on Ubuntu ?

ClamTK is a free tool that you can use to easily manage the ClamAV anti-malware software through a graphical user interface. This can be used as an alternative to the clamscan command-line tool.

To install ClamTK, run the following command:

$ sudo apt-get install clamtk


How to Launch ClamTK on Ubuntu ?

You can launch ClamTK either from the Applications menu > Accessories or by running the following command in the Ubuntu terminal:

$ clamtk


How to Configure ClamTK ?

In the Virus Scanner window that appears, you will see options to quickly configure settings, perform a manual scan, schedule a scan, view the quarantine, and so on.


How to Configure clamtk settings ?

In the Virus Scanner main Window, click Settings and then check all options.

Then, Click Back to return to the main window.


How to Configure clamtk scheduler ?

1.  In the main window, click Scheduler

2.  Use the + and – buttons to set a time to scan your home directory

3.  Remember to click the big green plus icon to confirm your settings

4.  You should then see a message at the bottom of the window indicating that a daily scan has been scheduled


You could also schedule a time to manually update the ClamAV virus database if you wish. But you would first need to:

1.  Go back to the main window

2.  Click Update Assistant

3.  Choose “I would like to update signatures myself

4.  Apply the changes and then go back to Scheduler to set your preferred time

When you are done, remember to click the shiny star icon to confirm your schedule.


How to Perform a manual scan with ClamTK ?

1.  In the main Virus Scanner window, click either Scan a file or Scan a directory to perform a one-time scan of a file or folder respectively

2.  In the window that appears, click a location on the left and then select the specific file or folder on the right to scan

3.  Click OK to begin scanning.


How to Uninstall ClamAV from Ubuntu ?

The following command will uninstall ClamAV on Ubuntu:

$ sudo apt-get remove clamav*


How to Uninstall ClamTK from Ubuntu ?

The following command will uninstall ClamTK on Ubuntu:

$ sudo apt-get remove clamtk*


[Need urgent assistance in fixing missing packages on Ubuntu? We are available to help you today. ]


Conclusion