{"id":861,"date":"2018-10-09T23:50:02","date_gmt":"2018-10-09T20:50:02","guid":{"rendered":"http:\/\/kifarunix.com\/?p=861"},"modified":"2024-03-11T20:09:07","modified_gmt":"2024-03-11T17:09:07","slug":"how-to-install-and-use-clamav-antivirus-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-and-use-clamav-antivirus-on-ubuntu-18-04\/","title":{"rendered":"How to Install and Use ClamAV Antivirus on Ubuntu 18.04"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"697\" height=\"526\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/03\/clamav.png\" alt=\"Install and Use ClamAV Antivirus on Ubuntu\" class=\"wp-image-11896\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/03\/clamav.png 697w, https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/03\/clamav-150x113.png 150w, https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/03\/clamav-300x226.png 300w, https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/03\/clamav-557x420.png 557w, https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/03\/clamav-80x60.png 80w\" sizes=\"(max-width: 697px) 100vw, 697px\" \/><\/figure><\/div>\n\n\n<p>In this tutorial, you will learn how to install and use ClamAV antivirus on Ubuntu 18.04. <a href=\"https:\/\/www.clamav.net\/\" target=\"_blank\" rel=\"noopener noreferrer\">ClamAV<\/a> is an open source antivirus engine for detecting trojans, viruses, malware, adwares, rootkits and other malicious threats. It supports multiple file formats, file and archive unpacking, and multiple signature languages such as hash-based signature matching, wildcards, boolean logic and any custom rules written in Bytecode language.<\/p>\n\n\n\n<p>ClamAV includes a multi-threaded scanner daemon, command line utilities for on demand file scanning and automatic signature updates. One of its main uses is on mail servers as a server-side email virus scanner.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-and-use-clam-av-antivirus-on-ubuntu-18-04\">Installing and Use ClamAV Antivirus on Ubuntu 18.04<\/a><ul><li><a href=\"#install-clam-av-on-ubuntu-18-04\">Install ClamAV on Ubuntu 18.04<\/a><\/li><li><a href=\"#update-the-clam-av-singature-database\">Update the ClamAV Singature Database<\/a><\/li><li><a href=\"#clamscan-cli-options-and-example-usage\">Clamscan CLI Options and Example Usage<\/a><\/li><li><a href=\"#clam-av-return-codes\">ClamAV Return Codes<\/a><\/li><\/ul><\/li><li><a href=\"#other-tutorials\">Other Tutorials<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-and-use-clam-av-antivirus-on-ubuntu-18-04\">Installing and Use ClamAV Antivirus on Ubuntu 18.04<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-clam-av-on-ubuntu-18-04\">Install ClamAV on Ubuntu 18.04<\/h3>\n\n\n\n<p>ClamAV is available on Ubuntu repositories and thus&nbsp; you can run the command below to install it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update<\/code><\/pre>\n\n\n\n<pre id=\"block-d57e4cc1-ddc7-47e1-91dd-d58c49546139\" class=\"wp-block-preformatted\">apt install clamav clamav-daemon -y<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"update-the-clam-av-singature-database\">Update the ClamAV Singature Database<\/h3>\n\n\n\n<p>Once the installation is complete, you should update the ClamAV signatures.<\/p>\n\n\n\n<p>Stop the clamav-freshclam service and run the freshclam command to manually update the signatures database.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl stop clamav-freshclam<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>freshclam<\/code><\/pre>\n\n\n\n<p>Once the virus database update is done, start the clamav-freshclam service so it keeps updating the signature database in the background whenever.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start clamav-freshclam<\/code><\/pre>\n\n\n\n<p>You are now ready to use ClamAV to protect your system against viruses.<\/p>\n\n\n\n<p>ClamAV comes with a command line utility called <strong>clamscan<\/strong> that scans files and directories for viruses.<\/p>\n\n\n\n<p>To see the clamscan command line usage, run either of the commands below.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>clamscan &#8211;help<\/li>\n\n\n\n<li>man clamscan<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"clamscan-cli-options-and-example-usage\">Clamscan CLI Options and Example Usage<\/h3>\n\n\n\n<p>From the man pages, the clamscan command syntax is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>clamscan [options] [file\/directory\/-]<\/code><\/pre>\n\n\n\n<p>Some of the clamscan command options and their example usage is illustrated below;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\n<strong>-h, --help<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Print help information and exit.\n     # <strong>clamscan -h<\/strong>      \n<strong>-V, --version<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Print version number and exit.\n     <strong># clamscan -V<\/strong>\n<strong>     ClamAV 0.100.1\/25021\/Tue Oct  9 15:52:08 2018<\/strong>\n<strong>--no-summary<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Do not display summary at the end of scanning.\n     <strong># clamscan --no-summary \/home\/<\/strong>\n<strong>-i, --infected<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Only print infected files.\n     <strong># clamscan -i \/home\/<\/strong>\n<strong>-o, --suppress-ok-results<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Skip printing OK files \n<strong>--bell<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Sound bell on virus detection.\n<strong>     # clamscan -r --bell -i \/home<\/strong>\n<strong>-d FILE\/DIR, --database=FILE\/DIR<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Load virus database from FILE or load all virus database files from DIR.\n     <strong># clamscan -d \/tmp\/newclamdb -r \/tmp<\/strong>\n<strong>-l FILE, --log=FILE<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Save scan report to FILE.\n<strong>-r, --recursive<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Scan directories recursively. All the subdirectories in the given directory will be scanned.\n     <strong># clamscan -r --remove \/<\/strong>\n<strong>-f FILE, --file-list=FILE<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Scan files listed line by line in FILE. \n<strong>--remove[=yes\/no(*)]<\/strong>\n\u00a0\u00a0\u00a0\u00a0 Remove infected files. Be careful as this removes file completely.\n     <strong>#\u00a0clamscan -r --remove \/home\/USER<\/strong><code>\n<\/code><strong>--move=DIRECTORY<\/strong>\n    Move infected files into DIRECTORY. Directory must be writable for the user or unprivileged user running clamscan.\n    <strong># clamscan -r --move=\/home\/USER\/VIRUS \/home\/<\/strong>\n<strong>--copy=DIRECTORY<\/strong>\n    Copy infected files into DIRECTORY. Directory must be writable for the user or unprivileged user running clamscan.\n    <strong># clamscan -r --copy=\/home\/USER\/VIRUS \/home\/<\/strong>\n<\/code><\/pre>\n\n\n\n<p>Note that most of the options are simple switches which enable or disable some features. Options marked with [=yes\/no(*)] can be optionally followed by <strong>=yes <\/strong>or <strong>=no. <\/strong>If they get called without the boolean argument the scanner will assume &#8216;yes&#8217;. The asterisk marks the default internal setting for a given option.<\/p>\n\n\n\n<p>For a comprehensive list of options, check the clamscan man pages<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>man clamscan<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"clam-av-return-codes\">ClamAV Return Codes<\/h3>\n\n\n\n<p>The following are the exit return codes for ClamAV.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>0 : No virus found.<\/li>\n\n\n\n<li>1 : Virus(es) found.<\/li>\n\n\n\n<li>2 : Some error(s) occured.<\/li>\n<\/ul>\n\n\n\n<p>Before we can wrap up this tutorial, it is good to understand that clamscan can be CPU intensive. To limit the clamscan CPU time to certain levels, you can use two tools; <strong>nice<\/strong> and <strong>cpulimit<\/strong> commands. <span class=\"comment-copy\"><strong>cpulimit<\/strong> limits absolute cpu time, and nice lowers the priority of clamscan (limits relative cpu time).<\/span><\/p>\n\n\n\n<p>To use nice command,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>nice -n 15 clamscan &amp;&amp; clamscan -ir \/<\/code><\/pre>\n\n\n\n<p>As long as no other process requires cputime, clamscan will maximize it. But as soon as another process with a higher priority needs cputime, clamscan will lost it.<\/p>\n\n\n\n<p>Using cpulimit;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cpulimit -z -e clamscan -l 50 &amp; clamscan -ir \/<\/code><\/pre>\n\n\n\n<p>That concludes our guide on how to install and use ClamAV Antivirus on Ubuntu 18.04.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h2>\n\n\n\n<p><a title=\"How to Install RKHunter (RootKit Hunter) On Ubuntu 18.04\" href=\"https:\/\/kifarunix.com\/how-to-install-rkhunter-rootkit-hunter-on-ubuntu-18-04\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">How to Install RKHunter (RootKit Hunter) On Ubuntu 18.04<\/a><\/p>\n\n\n\n<p><a title=\"Install OpenVAS 9 with PostgreSQL in Ubuntu 18.04\" href=\"https:\/\/kifarunix.com\/install-openvas-9-with-postgresql-in-ubuntu-18-04\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">Install OpenVAS 9 with PostgreSQL in Ubuntu 18.04<\/a><\/p>\n\n\n\n<p><a title=\"How to Install and Configure Maltrail on Ubuntu 18.04\" href=\"https:\/\/kifarunix.com\/how-to-install-and-configure-maltrail-on-ubuntu-18-04\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">How to Install and Configure Maltrail on Ubuntu 18.04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to install and use ClamAV antivirus on Ubuntu 18.04. ClamAV is an open source antivirus engine for detecting<\/p>\n","protected":false},"author":1,"featured_media":11896,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[34,168,121],"tags":[170,169,171,6677,4721,67],"class_list":["post-861","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security","category-antivirus","category-howtos","tag-antivirus","tag-clamav","tag-clamtk","tag-install-clamav-on-linux","tag-install-clamav-on-ubuntu","tag-ubuntu-18-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/861"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=861"}],"version-history":[{"count":14,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/861\/revisions"}],"predecessor-version":[{"id":21041,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/861\/revisions\/21041"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/11896"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}