In this article, we will go through how to install ClamAV on Rocky Linux 9. Clam AntiVirus is a free, multi-platform antimalware toolset that can find various forms of malware, including viruses. Though it was created for Unix, it is also available in third-party versions for AIX, BSD, HP-UX, Linux, macOS, OpenVMS, OSF, and Solaris.
How to Install ClamAV on Rocky Linux 9
- Update your system packages using the command below.
sudo dnf update
- Next, install the EPEL repository using the following command.
sudo dnf install epel-release -y
- Then install ClamAV on Rocky Linux 9.
sudo dnf install clamav clamd clamav-update
Sample output
Dependencies resolved. =================================================================== Package Arch Version Repo Size =================================================================== Installing: clamav x86_64 0.103.6-1.el9 epel 2.3 M clamav-update x86_64 0.103.6-1.el9 epel 94 k clamd x86_64 0.103.6-1.el9 epel 96 k Installing dependencies: clamav-filesystem noarch 0.103.6-1.el9 epel 19 k clamav-lib x86_64 0.103.6-1.el9 epel 823 k libprelude x86_64 5.2.0-9.el9 epel 330 k Transaction Summary =================================================================== Install 6 Packages Total download size: 3.6 M Installed size: 180 M Is this ok [y/N]: y Downloading Packages: (1/6): clamav-filesystem-0.103.6-1 11 kB/s | 19 kB 00:01 (2/6): clamav-update-0.103.6-1.el9 59 kB/s | 94 kB 00:01 (3/6): clamav-lib-0.103.6-1.el9.x8 135 kB/s | 823 kB 00:06 (4/6): clamd-0.103.6-1.el9.x86_64. 3.7 kB/s | 96 kB 00:26 (5/6): libprelude-5.2.0-9.el9.x86_ 11 kB/s | 330 kB 00:29 (6/6): clamav-0.103.6-1.el9.x86_64 39 kB/s | 2.3 MB 00:59 ------------------------------------------------------------------- Total 56 kB/s | 3.6 MB 01:05 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : libprelude-5.2.0-9.el9.x86_64 1/6 Running scriptlet: clamav-filesystem-0.103.6-1.el9.noarch 2/6 Installing : clamav-filesystem-0.103.6-1.el9.noarch 2/6 Installing : clamav-lib-0.103.6-1.el9.x86_64 3/6 Installing : clamav-update-0.103.6-1.el9.x86_64 4/6 Running scriptlet: clamav-update-0.103.6-1.el9.x86_64 4/6 Installing : clamav-0.103.6-1.el9.x86_64 5/6 Running scriptlet: clamav-0.103.6-1.el9.x86_64 5/6 Running scriptlet: clamd-0.103.6-1.el9.x86_64 6/6 Installing : clamd-0.103.6-1.el9.x86_64 6/6 Running scriptlet: clamd-0.103.6-1.el9.x86_64 6/6 Verifying : clamav-0.103.6-1.el9.x86_64 1/6 Verifying : clamav-filesystem-0.103.6-1.el9.noarch 2/6 Verifying : clamav-lib-0.103.6-1.el9.x86_64 3/6 Verifying : clamav-update-0.103.6-1.el9.x86_64 4/6 Verifying : clamd-0.103.6-1.el9.x86_64 5/6 Verifying : libprelude-5.2.0-9.el9.x86_64 6/6 Installed: clamav-0.103.6-1.el9.x86_64 clamav-filesystem-0.103.6-1.el9.noarch clamav-lib-0.103.6-1.el9.x86_64 clamav-update-0.103.6-1.el9.x86_64 clamd-0.103.6-1.el9.x86_64 libprelude-5.2.0-9.el9.x86_64 Complete!
- Configure SELinux for ClamAV.
sudo setsebool -P antivirus_can_scan_system 1
- Update ClamAV virus database.
sudo freshclam
- After updating, let’s create freshclam systemd file.
sudo nano /usr/lib/systemd/system/freshclam.service
Paste the config below then save(ctrl+s) and close(ctrl+x) the file.
[Unit] Description = ClamAV Scanner After = network.target [Service] Type = forking ExecStart = /usr/bin/freshclam -d -c 1 Restart = on-failure PrivateTmp =true [Install] WantedBy=multi-user.target
- Start FreshClam and ClamD service using the command below.
sudo systemctl start freshclam
- Then enable it to start on boot.
sudo systemctl enable freshclam
- It should be up and running, check the status using the following command.
sudo systemctl status freshclam
Sample output
● freshclam.service - ClamAV Scanner Loaded: loaded (/usr/lib/systemd/system/freshclam.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2022-07-28 00:11:13 EAT; 7min ago Main PID: 7773 (freshclam) Tasks: 1 (limit: 23284) Memory: 2.1M CPU: 34ms CGroup: /system.slice/freshclam.service └─7773 /usr/bin/freshclam -d -c 1 Jul 28 00:11:13 localhost.localdomain systemd[1]: Starting ClamAV Scanner... Jul 28 00:11:13 localhost.localdomain systemd[1]: Started ClamAV Scanner.
- Enable LocalSocket using the following command.
sudo sed -i 's/#LocalSocket \/run/LocalSocket \/run/g' /etc/clamd.d/scan.conf
- Start Clamd scanner.
sudo systemctl start clamd@scan
- Enable Clamd scanner to start on boot.
sudo systemctl enable clamd@scan
- Next, check its status using the command below.
sudo systemctl status clamd@scan
Sample output
● [email protected] - clamd scanner (scan) daemon Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled; vendor preset: disabled) Active: active (running) since Thu 2022-07-28 00:25:03 EAT; 7s ago Docs: man:clamd(8) man:clamd.conf(5) https://www.clamav.net/documents/ Process: 8046 ExecStart=/usr/sbin/clamd -c /etc/clamd.d/scan.conf (code=exited, status=0/SUCCESS) Main PID: 8047 (clamd) Tasks: 2 (limit: 23284) Memory: 1.2G CPU: 31.851s CGroup: /system.slice/system-clamd.slice/[email protected] └─8047 /usr/sbin/clamd -c /etc/clamd.d/scan.conf Jul 28 00:25:03 localhost.localdomain clamd[8047]: ELF support enabled. Jul 28 00:25:03 localhost.localdomain clamd[8047]: Mail files support enabled. Jul 28 00:25:03 localhost.localdomain clamd[8047]: OLE2 support enabled. Jul 28 00:25:03 localhost.localdomain systemd[1]: Started clamd scanner (scan) daemon. Jul 28 00:25:03 localhost.localdomain clamd[8047]: PDF support enabled. Jul 28 00:25:03 localhost.localdomain clamd[8047]: SWF support enabled. Jul 28 00:25:03 localhost.localdomain clamd[8047]: HTML support enabled. Jul 28 00:25:03 localhost.localdomain clamd[8047]: XMLDOCS support enabled. Jul 28 00:25:03 localhost.localdomain clamd[8047]: HWP3 support enabled. Jul 28 00:25:03 localhost.localdomain clamd[8047]: Self checking every 600 seconds.
Scan files and directories using ClamAV on Rocky Linux 9
- 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
Remove threats found in files and directories using ClamAV
- 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
Uninstall ClamAV on Rocky Linux 9
- Run the command below to remove ClamAV.
sudo dnf remove clamav clamd clamav-update
- You have made it to the end of our article. We have gone through how to install ClamAV on Rocky Linux 9.
Read more on ClamAV Documentation
Other Tutorials
Install Ubuntu Mate 22.04 LTS on VirtualBox