ClamAV free & open-source antivirus software that be used to detect virus, trojans, rootkits, malware etc. It is widely used on Linux system to detect the above-mentioned threats.

As compared to the Windows systems, Linux systems are not widely affected by viruses. trojans etc but whatever small chances are there, it is wise to protect the systems against such threats. This especially wise when critical systems and data are involved.

Recommended Read: How to install Google Cloud SDK in Linux

Also Read: Importance TERRAFORM commands that we should know

In this tutorial, we will learn how to install ClamAV on Ubuntu & will also discuss various commands to use the ClamAV on Ubuntu systems.


Install ClamAV on Ubuntu

ClamAV is maintained in the default Ubuntu repositories, so we are not required to add any other repos. So to install ClamAV on Ubuntu, we can just run the following command,

$ sudo apt install clamav

Once the ClamAV has been installed on the Ubuntu systems, we can confirm it by checking it’s version with the following command,

https://services.vlitag.com/vpaid/?q=9ba3f2539ddb6b2df45a4f25fbfd7843&defaultVolume=&page_url=https://linuxtechlab.com

$ clamav --version

Now let’s discuss how to use ClamAV on Ubuntu machines.


Use ClamAV

1- Update the virus database of ClamAV

Run the following command to update the ClamAV virus database,

$ freshclam

It is recommended to run this command before you run the scan for the system. You can also schedule a cron job for the same,

$ crontab -e

0 6 * * * /usr/bin/freshclam

This will update the database every day at 6 AM.


2-  Run a system scan

Use the following command to scan the Ubuntu system,

$ clamscan


3- Redirect output of scans to a file

To send the output of the scan, run the following command,

$ clamscan > output.txt


4- To show only infected files in the output

Use the following command to show only the infected files in the output rather than showing all the scanned files,

$ clamscan -i

To also sound an alert bell once an infected is detected, use the following command,

$ clamscan -i --bell


5- Scan a single folder

To scan only a single folder use the following command,

$ clamscan -ir /home/shusain > output.txt

This command will only scan the folder /home/shusain. So these were some examples of how to use the ClamAV on Ubuntu. These are only the most command used options with clamav, there are plenty of other options that can be used. You can check all the options that can be used clamav with the following command,

$ clamscan --help

This completes our tutorial on how to install ClamAV on Ubuntu & also we discussed how to use the ClamAV. Please do send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter

Linux TechLab is thankful for your continued support.