23.9 C
Senior Writer and partner

Install ClamAV on Debian 10 / Debian 9/ Ubuntu 20.04/ 18.04

Are there viruses in Linux? The answer is yes, the point is that Linux is a very secure system that minimizes risks. However, when you use a Linux server on a network where there are many clients using Windows, it is useful to install ClamAV to remove those viruses.

ClamAV is an open source antivirus engine for detecting Trojans, viruses, malware and other malicious threats. Of course, it is available for the most common Linux distributions including Debian, Ubuntu, and CentOS.

In case you didn’t know, ClamAV is the standard for mail gateway scanning software. Of course, we are talking about the open source area. This tells you how powerful and reliable it is. All this, with a high performance, which assures you that you will not have an unnecessary expense of computer resource.

Let’s install ClamAV on Debian 10 / Debian 9.

1. Install ClamAV

- Advertisement -

Installing ClamAV is really simple because it is available in the main repositories of most Linux distributions.

In case you are using Fedora:

:~$ sudo dnf install clamav

For CentOS 7:

:~$ sudo yum install clamav-server clamav-data clamav-update clamav-filesystem clamav clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd

To install ClamAV in OpenSuse, just run:

:~$ sudo zypper install clamav

And for Debian and Ubuntu:

:~$ su
:~# apt update && sudo apt upgrade
:~# apt-get install clamav clamav-daemon

1.- Upgrading the system
1.- Upgrading the system

2.- Install ClamAV on Debian
2.- Install ClamAV on Debian

The installation is done.

2. Using ClamAV

Like any antivirus, its effectiveness depends on how often you update your virus definition. So the first step is to update ClamAV.

:~# freshclam

3.- Refreshing the clamav database
3.- Refreshing the ClamAV database

Next, scan a directory.

:~# clamscan -r /home/angelo

4.- Scanning a directory
4.- Scanning a directory

The -r option is for recursively search.

In this case, ClamAV doesn’t detect any viruses because I literally don’t have any. It is practically a clean Debian installation.

I got an infected file, let’s see how ClamAV treats it.

5.- An infected file found
5.- An infected file found

As you can see, ClamAV found the infected file. Now, remove it.

:~# clamscan --infected --remove --recursive /home/angelo

6.- Removing an infected file
6.- Removing an infected file

The above process is very easy but it is not a good idea if it has to be done frequently. So, initialize the ClamAV daemon to constantly look for threats.

:~# systemctl start clamav-daemon
:~# systemctl start clamav-freshclam

Finally, you can consult the rest of ClamAV usage using its help. It is important to know other options of use and configuration.

:~# clamav --help

8.- Other clamav options
7.- Others ClamAV options

And that’s it for now.


It is important to know how to use ClamAV on Linux because security is an issue that should not be taken lightly. Its installation and use are quite simple but because it is open source it guarantees a correct and frequently updated database.

Please share this post with your friends.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"


  1. That’s what I got after installation:
    ERROR: /var/log/clamav/freshclam.log is locked by another process
    ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).
    ERROR: initialize: libfreshclam init failed.
    ERROR: Initialization error!

    and after trying to scan:
    /home/angelo: No such file or directory
    WARNING: /home/angelo: Can’t access file

  2. @KJ
    1. stop the freshclamservice by sudo systemctl stop clamav-freshclam the continue everything from point 2 onwards and it should work


Please enter your comment!
Please enter your name here

Latest article