Saturday, April 20, 2024
HomeTutorialsHow to Install and Use ClamAV Antivirus on Ubuntu Linux

How to Install and Use ClamAV Antivirus on Ubuntu Linux

ClamAV is one of the best-recommended antiviruses for Ubuntu. Of course, you will be cynical if I say instead of being a modern Ubuntu user, sometimes you might need an antivirus as we all know that Linux is always unsinkable in the sea of the virus. But, this notion is not valid in some cases. If your system is connected with the internet, there are thousands of ways you can carry the virus in your Ubuntu system. For security purposes, Ubuntu often needed to be checked up; It’s good to maintain a healthy operating system without having any virus attack. And no doubt, ClamAV Antivirus is the finest and most used antivirus for the Ubuntu system.

ClamAV Antivirus on Ubuntu

image 1 for postIf you have to deal with public domains or third party databases, there is a chance that your Linux system can get infected with the virus. Mostly, Linux viruses are trojan and malicious files. Ubuntu, the leading Linux operating system in the world, runs a vast amount of file servers, where there is a huge chance to get malicious emails or malicious SQL injection form evil users.

To protect your Ubuntu system or database from hackers, it’s a wise decision to have an antivirus. And for Ubuntu, no other antiviruses can be as effective and powerful as ClamAV. ClamAV can scan, find, and remove all infected files and software from your Ubuntu machine. ClamAV can also defend the local attacks delivered by ethical or unethical hackers. In this blog post, we will see how to install and use the ClamAV Antivirus in any Ubuntu machine.

Install of ClamAV Antivirus in Ubuntu Linux

ClamAV claims that it can be installed in all Debian distributions of the Linux like Ubuntu, Linux Mint, Elementary OS, Debian OS, etc. Here I’m going to start the method of installing ClamAV Antivirus in Ubuntu. Be mindful that before installing any software in Ubuntu, you should keep your Ubuntu repository up to date.

Step 1: Get Your Ubuntu System Updated

So first thing first. Let’s update our Ubuntu machine; later, when the file repository will be updated, we will initialize the process of installing ClamAV. For now, I will be using the Advanced Package Tool apt command in the terminal to get updated.

$ sudo apt-get update
$ sudo -E apt-get update
$ sudo apt update

Step 2: Installing ClamAV in Ubuntu

Installing ClamAV Antivirus in your Ubuntu is very simple. All you need is to run an apt install command in your system terminal. For installing ClamAV in the background process, I’m adding a daemon with the terminal command. You can also check the version of your ClamAV by using the following command in the terminal.

$ sudo apt-get install clamav clamav-daemon
$ clamscan --version

So far, you’ve successfully installed ClamAV Antivirus in your Ubuntu system. But like Windows antiviruses, the Ubuntu antiviruses don’t always run in the system background. ClamAV only runs when the system administrator asks it for any particular job. Otherwise, it keeps sleeping.

terminal command If you are a Linux system administrator, and if you think that something wrong is happening inside your Linux server or filesystem, you can also install ClamAV on your website C-panel.

Step 3: Update the ClamAV Signature Database Automatically

In Ubuntu, the ClamAV signature database is the special database for your ClamAV antivirus, where all the local software, log files, and system files kept safely. Only you can get access to your ClamAV signature database from your Ubuntu system. ClamAV Antivirus signature database keeps unwanted users away from your Ubuntu system.

When any update comes for ClamAV, the corresponding files are also updated inside the ClamAV signature database. Moreover, the ClamAV signature database also allows users to use ClamAV in offline. To install the ClamAV signature database in your Ubuntu, you need to stop your running ClamAV in your machine. To stop the freshclam, simply follow the terminal command.

$ sudo systemctl stop clamav-freshclam

Now when the background process of ClamAV Antivirus is stopped, you can run the following terminal command in your Ubuntu machine to update the ClamAV database automatically. You can also update your ClamAV signature database manually; we will also see that process after a while.

$ sudo freshclam

clamAv ubuntu- freshclam

Step 4: Update the ClamAV Signature Database Manually

If you think you won’t be able to run the above terminal command to get an automatic update of your ClamAV database, there is a second method to update your signature database. You can download the ClamAV signature database from the official directory of ClamAV.

Download ClamAV Database

After you have downloaded the ClamAV signature database, now all you need is to place the file in your local directory of ClamAV. You can use the following mkdir terminal command to create a directory for ClamAV, or you can also find your var/lib directory and create a new folder then rename it with ClamAV.

$ sudo mkdir /var/lib/clamav

Now you’ve to move the ClamAV signature database inside the directory. Again, you can either use the following terminal command to move the file, or you can do that in the traditional manual way.

$ cp daily.cvd /var/lib/clamav/daily.cvd

Step 5: Starting ClamAV Antivirus in Ubuntu

Finally, so far, you’ve done the procedure of installing the ClamAV antivirus inside your Ubuntu machine. Now it’s high time to open the ClamAV. To open the ClamAV antivirus, just type the following terminal command in your Ubuntu machine. Later, we will see how to use ClamAV and how to remove harmful and malicious files from our system.

$ sudo systemctl start clamav-freshclam

ClamTK, the GUI Control Panel of ClamAV

Those who have recently moved on Ubuntu from Windows might not be familiar with the method of using terminal commands. For them, ClamAV has built a graphical user interface(GUI) control panel. The GUI panel of ClamAV is known as ClamTK. Now we will see how to install ClamTK in our Ubuntu machine. To install ClamTK on Ubuntu, just follow the terminal command in your machine.

$ sudo apt-get install clamtk

clamav ubuntu clamtk

Main Features of ClamTk on Ubuntu

The main features of ClamTK are shortlisted here. This might be helpful to you, have a glance.

  • Scan files that are larger than 20MB
  • Make a whitelist of directory or software
  • Schedule the antivirus for checking up
  • Scan your network addresses
  • Scan emails and web browsers
  • Scan a specific file or directory
  • Analysis system health
  • Check the previous history
  • Quarantine any apps or files for a certain period

How to Use ClamAV on Ubuntu

After the installation process of ClamAV and ClamTK are done inside your Ubuntu machine, now you are good to go for a test run. Very first, you can check the to-do list of ClamAV. You can find what you can do with ClamAV. To get the to-do list of ClamAV, open your terminal and type the following command line in the terminal. A new list will be generated in your terminal, showing the capabilities of ClamAV Antivirus.

$ clamscan --help

You can scan and get auto-remove trojan and malicious files from your Ubuntu system with ClamAV. For that, type the command kept below in your terminal. But my recommendation will be not to use the autoremove command, because if you’re using a dual boot machine, sometimes ClamAV recognizes and removes all other operating directories as a virus. This can become a huge loss of data from your machine.

$ sudo apt-get autoremove
$ sudo clamscan --infected --remove --recursive

You can also scan any specific directory or file in your Ubuntu by ClamAV. For that, you can use the remove infected -r-i- command in the terminal. Every time the ClamAV finds an infected file, it will ring a bell. For example, let me want to scan my Downloads directory, for that my command will be like the command given below.

$ clamscan -r-i --bell ~/Downloads

Removing ClamAV from Ubuntu

It is true that, like other Linux distributions, Ubuntu also doesn’t require any third-party anti-virus protection. But in case if you need to check the health of your system, you have ClamAV. But what to do when you don’t need ClamAV anymore! Yes, you can remove/uninstall the ClamAV Antivirus from your Ubuntu system.

Basically, Ubuntu users install ClamAV occasionally just to checkup the system condition and remove it after they are done checking. So, if you need to remove ClamAV from your Ubuntu, here is the terminal command to do so.

$ sudo apt-get remove clamav clamav-daemon

remove clamav from ubuntu

Final Thoughts

Ubuntu Linux, the leading open-source operating system, doesn’t require any third-party antivirus as Windows requires. But in case any malicious or trojan files get mixed with your system files, it is necessary to check your Ubuntu system with ClamAV. Using ClamAV is a relief and hassle-free, because, like Windows, it doesn’t keep running in the background or doesn’t show any annoying pop-up window.

In the entire post, I’ve tried to describe all the process of how to install and use ClamAV Antivirus in your Ubuntu machine. I’ve also covered pretty much about why you might need an antivirus in your Linux machine. And at the last part, I’ve also detailed the process of how to uninstall ClamAV Antivirus from your Ubuntu machine.

So, what do you think? Does Ubuntu require any third party antivirus? If the answer is yes, tell us about your experience. Fell free to share your thoughts with us. You can also share this post with your Linux geeky friends.

Mehedi Hasan
Mehedi Hasan
Mehedi Hasan is a passionate enthusiast for technology. He admires all things tech and loves to help others understand the fundamentals of Linux, servers, networking, and computer security in an understandable way without overwhelming beginners. His articles are carefully crafted with this goal in mind - making complex topics more accessible.


  1. Excellent post – thanks for that.

    One question I have is that while you make the point that Ubuntu is inherently virus resistant, if wine is installed to run MS Windows programs within Ubuntu does the OS become susceptible to MS Windows based viruses ?

    • Most viruses (99.9%) are written for a certain OS. So if you run Wine and a Windows virus gets into Wine, than that might affect Wine and it’s programs, but it would not infect Linux. However, if a very clever person writes a virus to detect it is running in Wine, and then somehow cleverly infects Linux with a virus, I would not rue out that is possible, but I have never heard of it. Besides, It not only needs to detect it is running in Wine, it also would need to detect what version Linux is running Wine, because most versions work differently and therefore would have to infect Linux in a different way.
      I think the change than a (any) person on Earth will be killed by an asteroid from the other side of the Universe is higher than Linux being infected through a Windows virus.


Please enter your comment!
Please enter your name here

You May Like It!

Trending Now