Setting up ClamAV on macOS
My preferred anti-virus system is ClamAV and I had trouble getting it running on macOS recently. Here’s how I got it going so if you’re running to the same issue, this should solve your problem.
I will go through the steps I took and problems encountered. This article will take you less than three minutes to read.
Installing ClamAV on macOS
To get ClamAV running on macOS, run: brew install clamav
$ brew install clamav
==> Installing dependencies for clamav: json-c, pcre, jansson, libmagic and yara
==> Installing clamav dependency: json-c
==> Downloading https://homebrew.bintray.com/bottles/json-c-0.13.1.mojave.bottle.tar.gz
######################################################################## 100.0%
...
######################################################################## 100.0%
==> Pouring clamav-0.101.2.mojave.bottle.tar.gz
==> Caveats
To finish installation & run clamav you will need to edit
the example conf files at /usr/local/etc/clamav/
==> Summary
🍺 /usr/local/Cellar/clamav/0.101.2: 42 files, 3.6MB
==> Caveats
==> clamav
To finish installation & run clamav you will need to edit
the example conf files at /usr/local/etc/clamav/
Thanks to brew
, open source software like ClamAV can run on multiple
platforms.
Running ClamAV
Normally, I would just run the application directly, in this case:
clamav
, but that does not exist. The main application is: clamscan
$ clamscan
LibClamAV Error: cli_loaddbdir(): No supported database files found in /usr/local/Cellar/clamav/0.101.3/share/clamav
ERROR: Can't open file or directory
Hmm. What is going on here?
After looking up the man page, man clamscan
, one related package is
freshclam
, that has a description:
freshclam - update virus databases
Aah - let’s run freshclam
to update the definition!
$ freshclam
ERROR: Can't open/parse the config file /usr/local/etc/clamav/freshclam.conf
Well, there’s no such file, or where do I get it? Is there a sample somewhere?
Getting freshclam.conf
Well, it turns out I missed a critical line in the brew
install, which was:
To finish installation & run clamav you will need to edit the example conf files at /usr/local/etc/clamav/
🤦♂️ whoops! I didn’t even look (and only when writing up this article, I noticed it).
Let’s make the freshclam.conf
file by running command:
$ mv /usr/local/etc/clamav/freshclam.conf.sample /usr/local/etc/clamav/freshclam.conf
Change the following in the file from:
# Comment or remove the line below.
Example
To:
# Comment or remove the line below.
# Example
Update Database
Running the freshclam
application again results in:
$ freshclam
ClamAV update process started at Fri Aug 9 17:56:30 2019
Downloading main.cvd [ 41%]
Great! Now macOS can scan virus too!
Solution Source
I can’t take credit for everything, I found this github comment that basically describes the solution I presented.
I have this article as a way for me to remember but also remind myself of apps that are better on Linux than macOS.
Conclusion
Getting ClamAV running on macOS isn’t that hard, but I was close to giving up!.
I love using open source software and macOS. As macOS is UNIX based, almost all open source software works on macOS.
There are times where just using Linux to run open source software is a better experience than macOS. ClamAV is one of those times.
Hopefully, this post has helped you from giving up on open source software!