In this tutorial, we will show you how to install ClamAV on Rocky Linux 9. For those of you who didn’t know, ClamAV is an open-source antivirus engine for detecting trojans, viruses, malware, adware, rootkits, and other malicious threats. ClamAV offers a Command-line scanner, a Milter interface for Sendmail, an Advanced database updater, and built-in support for archive formats, ELF executables + Portable Executable files, and popular document formats. Though it was created for Unix, it is also available in third-party versions for BSD, Linux, macOS, OpenVMS, OSF, and Solaris.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the ClamAV open-source antivirus on Rocky Linux. 9.
- A server running one of the following operating systems: Rocky Linux 9.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install ClamAV on Rocky Linux 9
Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:
sudo dnf check-update sudo dnf install dnf-utils sudo dnf install epel-release
Step 2. Installing ClamAV on Rocky Linux 9.
By default, ClamAV is not available on Rocky Linux 9 base repository. Now run the following command below to install the latest stable version of the ClamAV using the following command below:
sudo dnf install clamav clamd clamav-update
To verify if the installation was successful and to confirm the version and build use the following:
Step 3. Setup SELinux for ClamAV.
Now we run the below command to configure SELinux for ClamAV:
sudo setsebool -P antivirus_can_scan_system 1
Step 4. Update the ClamAV Virus Database.
For scanning to work, you need an updated virus database. There are two options for updating the ClamAV database:
clamav-freshclam: updates the database from the Internet. This is recommended with Internet access.
Offline updatefor systems with no direct internet access.
Now you can proceed to update your virus definition database by the following terminal command:
After the database has been updated, you can start the
(clamav-freshclam) service, so it keeps updating the signature database in the background with the following command below:
sudo systemctl start clamav-freshclam
It should be up and running, check the status using the following command:
sudo systemctl status clamav-freshclam
Step 5. Use Clamav antivirus to Scan files.
- To scan a specific file, run the command below followed by the file name.
sudo clamscan filename
- To scan a specific directory, run the following command followed by a directory name.
sudo clamscan -r directoryname
- To remove threats found in the file, run the command below followed by the filename.
sudo clamscan --remove filename
- To remove threats found in the directory, run the following command followed by the directory name.
sudo clamscan -r --remove directoryname
- Print help information using
Congratulations! You have successfully installed ClamAV. Thanks for using this tutorial for installing ClamAV open-source antivirus on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official ClamAV website.