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
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,
$ clamav --version
Now let’s discuss how to use ClamAV on Ubuntu machines.
1- Update the virus database of ClamAV
Run the following command to update the ClamAV virus database,
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,
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.