Blog

Thoughts from my daily grind

Install & Configure ClamAV - macOS & Linux Free Antivirus Solution

Posted by Ziyan Junaideen |Published: 08 October 2021 |Category: Technology
Firewall |

ClamAV (Clam AntiVirus) is the leading antivirus software solution for Linux, also available for macOS. A FOSS (free and open-source) high-performance command-line interface application with multi-threaded scanning and automatic signature updates.

Why install an antivirus solution?

The reason is simple; an antivirus solution works like a vaccine; it keeps both you and your loved ones safe.

It is true that Linux and macOS are secure than Windows and suffer much fewer (but not none) virus and malware intrusions, but you can never be too safe. In addition, it is free.

Installation

This guide covers Ubuntu and macOS.

Ubuntu

You can install ClamAV and its daemon easily using the official software repositories.

sudo apt update
sudo apt install clamav clamav-daemon

macOS

Installation in macOS is a little more involved. Out of the box, macOS doesn't have a package manager like apt for Ubuntu but you can easily install Homebrew. This tutorial assumes that you have Homebrew installed.

Step 1: Install the application

brew intall clamav

Step 2: Setup configuration files

cd $(brew --prefix)/etc/clamav/

Step 2.1: Generate the clamd.conf file using clamd.conf.sample

cp clamd.conf.sample clamd.conf

Step 2.2: Generate the freshclam.conf file using the freshclam.conf.sample file.

cp freshclam.conf.sample freshclam.conf

Then open the freshclam.conf file and comment on the line (using #) that includes "Example" so that the file looks like this:

##
## Example config file for freshclam
## Please read the freshclam.conf(5) manual before editing this file.
##


# Comment or remove the line below.
# Example
#
# ...

Usage

First, you need to update the database including virus signatures. This is a download that is about 200mb.

freshclam

Example 1: Scan the current working directory

clamscan

Example 2: Scan a particular file

clamscan /path/to/file

Example 3: Recursively (-r) scan all files in a directory (or an external drive)

clamscan -r /path/to/directory

Example 4: You can also scan a stream of data

cat /path/to/streem | clamscan -

Conclusion

Installing and configuring ClamAV is easy. It has very little overhead. I usually use it to scan files/folders I receive from clients and pluggable media such as USB pen drives and external hard disks.

In my personal devices, I run the scan ad-hock. However I configure production servers to auto-update and run regular scans. In a future tutorial I will explain how you can periodically scan your system for virues

Tags
About the Author

Ziyan Junaideen -

Ziyan is an expert Ruby on Rails web developer with 8 years of experience specializing in SaaS applications. He spends his free time he writes blogs, drawing on his iPad, shoots photos.

Comments