{"id":3828,"date":"2021-01-27T17:20:48","date_gmt":"2021-01-27T17:20:48","guid":{"rendered":"https:\/\/linuxways.net\/?p=3828"},"modified":"2021-01-27T17:20:57","modified_gmt":"2021-01-27T17:20:57","slug":"how-to-install-clamav-anti-malware-protection-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-clamav-anti-malware-protection-on-ubuntu-20-04\/","title":{"rendered":"How to Install ClamAV Anti-Malware Protection on Ubuntu 20.04"},"content":{"rendered":"<p>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.<\/p>\n<p>In this guide, we will walk you through the steps to install ClamAV &#8212; an open-source anti-malware protection software developed by Cisco Systems. We will also install a graphical tool for using ClamAV called ClamTK.<\/p>\n<h2>Install ClamAV<\/h2>\n<p>First of all, run the following command to update the list of packages on Ubuntu if you have not done so in a while.<\/p>\n<pre>$<strong> sudo apt-get update<\/strong><\/pre>\n<p>Run the next command to begin installing ClamAV.<\/p>\n<pre>$<strong> sudo apt-get install clamav<\/strong><\/pre>\n<p>If prompted, enter <strong>y<\/strong> to continue installing ClamAV.<\/p>\n<h2>Download the Latest ClamAV Virus Database<\/h2>\n<p>ClamAV uses a frequently updated database of known viruses. The database files are stored in \/var\/lib\/clamav by default.<\/p>\n<p>First, run the command below to stop the ClamAV database updater service so that the necessary files can be successfully accessed.<\/p>\n<pre>$<strong> sudo systemctl stop clamav-freshclam<\/strong><\/pre>\n<p>Next, download the latest ClamAV virus database by running the following command.<\/p>\n<pre>$<strong> sudo freshclam<\/strong><\/pre>\n<p>You may now start the ClamAV database updater by running the command below.<\/p>\n<pre>$<strong> sudo systemctl start clamav-freshclam<\/strong><\/pre>\n<p>To ensure that the ClamAV database updater service is always started whenever the system boots, run the next command.<\/p>\n<pre>$<strong> sudo systemctl enable clamav-freshclam<\/strong><\/pre>\n<h2>Perform a Manual Scan with clamscan<\/h2>\n<p>For your basic scanning tasks, ClamAV includes a command-line tool called <strong>clamscan<\/strong>.<\/p>\n<p>The basic usage of the clamscan command is:<\/p>\n<pre>clamscan [options] [file or directory path to scan]<\/pre>\n<p>To see all available clamscan options, run:<\/p>\n<pre>$<strong> man clamscan<\/strong><\/pre>\n<p>Some common options for using <strong>clamscan<\/strong> include:<\/p>\n<p><strong>&#8211;log=file<\/strong> &#8211; to save the scan report to the specified file<\/p>\n<p><strong>&#8211;bell<\/strong> &#8211; to sound a bell when a virus is detected<\/p>\n<p><strong>&#8211;recursive<\/strong> &#8211; to scan all subfolders within the specified directory<\/p>\n<p><strong>&#8211;max-filesize=xm <\/strong>&#8211; to skip files larger than xm, where <strong>x<\/strong> is a number and <strong>m<\/strong> means megabytes<\/p>\n<p>For example, the following command scans everything in my home directory.<\/p>\n<pre>$ <strong>clamscan -r \/home\/shola<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"631\" height=\"239\" class=\"wp-image-3829\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-433.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-433.png 631w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-433-300x114.png 300w\" sizes=\"auto, (max-width: 631px) 100vw, 631px\" \/><\/strong><\/p>\n<p style=\"text-align: left;\"><strong>Figure 1:<\/strong> Perform a manual scan by using clamscan<\/p>\n<p>There were no infected files detected as denoted by <strong>Infected files: 0 <\/strong>in figure 1 above.<\/p>\n<h2>Schedule a Daily Scan<\/h2>\n<p>In order to schedule a daily scan, you could create a small script in \/etc\/cron\/cron.daily containing the <strong>clamscan<\/strong> instructions.<\/p>\n<p>Run the following command to create the script file.<\/p>\n<pre>$ <strong>sudo nano \/etc\/cron.daily\/clamscan_daily<\/strong><\/pre>\n<p>As an example, the script below will recursively scan my Downloads folder. You may copy this script but remember to edit the folder path to scan on the second line.<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<pre>#!\/usr\/bin\/env bash\n\nclamscan -r \/home\/shola\/Downloads<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Save changes and close the file.<\/p>\n<p>Next, run the command below to make the script file executable.<\/p>\n<pre>$ <strong>chmod +x \/etc\/cron.daily\/clamscan_daily<\/strong><\/pre>\n<p>The script will automatically run once a day.<\/p>\n<h2>Install ClamTK<\/h2>\n<p>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.<\/p>\n<p>To install ClamTK, run the following command.<\/p>\n<pre>$<strong> sudo apt-get install clamtk<\/strong><\/pre>\n<h2>Launch ClamTK<\/h2>\n<p>You can launch ClamTK either from the Applications menu &gt; Accessories or by running the following command in the Ubuntu terminal.<\/p>\n<pre>$<strong> clamtk<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"397\" height=\"335\" class=\"wp-image-3830\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-434.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-434.png 397w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-434-300x253.png 300w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/strong><\/p>\n<p><strong>Figure 2:<\/strong> Launch clamtk from Applications menu<\/p>\n<h2>Configure ClamTK<\/h2>\n<p>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, etc.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"497\" height=\"479\" class=\"wp-image-3831\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-435.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-435.png 497w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-435-300x289.png 300w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><\/strong><\/p>\n<p><strong>Figure 3:<\/strong> ClamTK virus scanner main window<\/p>\n<h3>Configure clamtk settings<\/h3>\n<p>In the Virus Scanner main Window, click <strong>Settings<\/strong> and then check all options as shown in figure 4 below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"497\" height=\"291\" class=\"wp-image-3832\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-436.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-436.png 497w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-436-300x176.png 300w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><\/p>\n<p><strong>Figure 4:<\/strong> Configure clamtk settings.<\/p>\n<p>Click <strong>Back<\/strong> to return to the main window.<\/p>\n<h3>Configure clamtk scheduler<\/h3>\n<p>1.\u00a0 In the main window, click <strong>Scheduler<\/strong><\/p>\n<p>2.\u00a0 Use the <strong>+<\/strong> and <strong>&#8211;<\/strong> buttons to set a time to scan your home directory<\/p>\n<p>3.\u00a0 Remember to click the big green plus icon to confirm your settings<\/p>\n<p>4.\u00a0 You should then see a message at the bottom of the window indicating that a daily scan has been scheduled<\/p>\n<p>In the example shown in figure 5 below, the scanner will run everyday at 10:09 PM local time.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"323\" height=\"487\" class=\"wp-image-3833\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-437.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-437.png 323w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-437-199x300.png 199w\" sizes=\"auto, (max-width: 323px) 100vw, 323px\" \/><\/p>\n<p><strong>Figure 5:<\/strong> Configure clamtk scheduler<\/p>\n<p>You could also schedule a time to manually update the ClamAV virus database if you wish. But you would first need to:<\/p>\n<p>1.\u00a0 Go back to the main window<\/p>\n<p>2.\u00a0 Click <strong>Update Assistant<\/strong><\/p>\n<p>3.\u00a0 Choose \u201cI would like to update signatures myself\u201d<\/p>\n<p>4.\u00a0 Apply the changes and then go back to <strong>Scheduler<\/strong> to set your preferred time<\/p>\n<p>When you are done, remember to click the shiny star icon to confirm your schedule.<\/p>\n<h2>Perform a manual scan with ClamTK<\/h2>\n<p>1.\u00a0 In the main Virus Scanner window, click either <strong>Scan a file<\/strong> or <strong>Scan a directory<\/strong> to perform a one-time scan of a file or folder respectively<\/p>\n<p>2.\u00a0 In the window that appears, click a location on the left and then select the specific file or folder on the right to scan<\/p>\n<p>3.\u00a0 Click OK to begin scanning<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"449\" height=\"191\" class=\"wp-image-3834\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-438.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-438.png 449w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/01\/word-image-438-300x128.png 300w\" sizes=\"auto, (max-width: 449px) 100vw, 449px\" \/><\/p>\n<p><strong>Figure 6: <\/strong>Scan a file by using clamtk<\/p>\n<h2>Uninstall ClamAV<\/h2>\n<p>The following command will uninstall ClamAV on Ubuntu.<\/p>\n<p>$<strong> sudo apt-get remove clamav*<\/strong><\/p>\n<h2>Uninstall ClamTK<\/h2>\n<p>The following command will uninstall ClamTK on Ubuntu.<\/p>\n<p>$<strong> sudo apt-get remove clamtk*<\/strong><\/p>\n<h2>Conclusion<\/h2>\n<p>In this guide, we have successfully installed and configured ClamAV and ClamTK to scan for malware on Ubuntu 20.04. If you have any questions or comments regarding this guide, please reach out to us via the comments section below.<\/p>","protected":false},"excerpt":{"rendered":"<p>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&hellip;<\/p>","protected":false},"author":28,"featured_media":3838,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[157,100],"class_list":["post-3828","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-clamav-anti-malware-protection","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/3828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=3828"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/3828\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/3838"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=3828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=3828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=3828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}