Install ClamAV Antivirus on Ubuntu Server/Desktop

Viruses, Trojans, and other forms of malware threats can be found in any operating system, so in today's environment every system, even Ubuntu Linux needs some kind of Antivirus solution.

Best Antivirus for Ubuntu Server/Desktop is ClamAV. It is a Free Open Source antivirus software solution that works pretty much the same as Windows Antivirus software.

To install ClamAV on your Ubuntu machine, enter the following command:

apt install clamav

Ubuntu Desktop users can install a graphical front end as well, known as ClamTk:

apt install clamtk

You can check ClamAV version by running the following command:

clamscan --version

Update Virus database/definitions

After the installation is completed, we should run the freshclam command to update the virus signature database.

First, we must stop the freshclam service:

systemctl stop clamav-freshclam.service

Next, update the database by running the following command:

sudo freshclam

After that Restart the freshclam:

systemctl start clamav-freshclam.service

ClamAV's ability of detecting the newest viruses largely depends on the signature database. For that reason we need to keep it up to date. However, you don't need to update the database manually. Freshclam service in Ubuntu runs in the background and periodically checks for updates throughout the day (12 times per day by default).

Download failed, Message: Timeout was reached, Can't download daily.cvd

If you received these errors when updating the virus definition, increase the ConnectTimeout and ReceiveTimeout values in /etc/clamav/freshclam.conf file. (0 means no timeout).

Scanning with ClamAV

ClamAV is capable of detecting viruses, Trojans, and other forms of malware. Scanning files for viruses is done with clamscan command.

sudo clamscan -ir /home/

In the example  we scan /home directory recursively using the -r option. The -i option is used so it will only output infected files as opposed to the name of every file it scans. Once the scan completes, it shows a summary as follows:

Scanning with clam antivirus in ubuntu

Ubuntu Desktop users can use the ClamTk graphical user interface, but the command line (clamscan command) is much faster than GUI.

Install ClamAV Antivirus on Ubuntu Server/Desktop