All about Audio and Video
Home>Howto>Control Virus Scans From The Command Line With Clam Antivirus [Linux]

Control Virus Scans From The Command Line With Clam Antivirus [Linux]

By Danny Stieben2013-02-04

clam antivirusThere are a few ways in which you can access Clam Antivirus for numerous purposes, such as removing viruses from Windows systems. First, there’s a front end to Clam Antivirus which you can use to perform tasks graphically. It is called Clamtk and has been featured on MakeUseOf before. By installing the graphical front end, your package manager should also pull in the Clam Antivirus engine that it depends on.

The other option is to skip the graphical interface and just use the Clam engine via the command line. Running the engine via the command line may be advantageous for a number of reasons, such as when issuing commands to another machine via SSH, or when you’re working on a weak system that lags under a graphical desktop environment. This is also good for servers, because they will most likely want to run antivirus scans to prevent the spread of viruses to whichever clients connect to the server.


Before you begin, it’d be best to go ahead and install the Clam antivirus engine. You can search through your respective package manager for “clam antivirus“, and then install the main package. All other dependencies should be pulled in automatically.

You can also run sudo apt-get install clamav clamav-freshclam if you’re running Ubuntu, or sudo yum install clamav clamav-updates if you’re running Fedora. As Clam is very lightweight as far as antivirus solutions go, it shouldn’t take very long at all to download and install the packages.

Updating Virus Definitions

clam antivirus

The first thing you’ll want to do after installing is update the virus definitions to be able to detect the latest threats. This can be easily accomplished by running the command sudo freshclam. It will instantly contact the Clam servers and download the latest definitions. The initial download will take a while as the definitions are newly downloaded.

Later updates should go a lot faster because freshclam will only download updates and not all definitions.

Sample Commands

clam antivirus

Once the virus definitions have been updated, you can start a scan with the clamscan command. Running clamscan --help in the terminal will spit out a lot of different options which you can use to customize how Clam scans your files. However, if you want to keep it rather simple, you can recursively scan the folder “user” within the home folder by running the command clamscan -r /home/user. The recursive flag “-r” is important because otherwise Clam would simply scan any files within the user folder, but nothing that’s inside a folder inside the user folder.

Of course, if you need to scan a different directory, you can adjust the path appropriately. If you have any other specific needs, do check out what clamscan --help outputs as everyone’s needs vary if they need anything else besides a simple recursive scan.


While Linux desktop users probably won’t have to worry about viruses or scanners, power users or those running servers will definitely like having this option to protect both the system as well as any connecting clients from malicious code. As Clam Antivirus is open source and free, it’s easy for anyone to use and install. No matter what your needs are, consider trying Clam Antivirus for any virus scanning and removal tasks.

Do you ever need to scan for viruses with Linux? What do you think about Clam Antivirus? Let us know in the comments!


Copyright A Free Codec .© 2011 - All rights reserved   Contact Us     

Choose language : Español 日本語 Deutsch Français