ClamAV is an open-source antivirus software used for detecting and removing viruses, trojans, and malware. Below are the basic usage methods for ClamAV:
-
Install ClamAV:
For Debian/Ubuntu systems, use the following commands to install:
sudo apt-get update sudo apt-get install clamav clamav-daemon
For CentOS/RHEL systems, use the following commands to install:
sudo yum install epel-release sudo yum install clamav clamav-update
-
Update the virus database:
Use the following command to update ClamAV's virus database:
sudo freshclam
If you encounter permission issues, try starting the freshclam daemon with sudo systemctl start clamav-freshclam
.
-
Scan files and directories:
Use the following command to scan a single file:
clamscan /path/to/your/file
Use the following command to scan an entire directory:
clamscan -r /path/to/your/directory
To automatically delete infected files during the scan, add the
--remove
parameter:clamscan -r --remove /path/to/your/directory
To generate a report after the scan is completed, add the
--log
parameter and specify the path for the report file:clamscan -r --log=/path/to/your/logfile /path/to/your/directory
-
Use the ClamAV daemon for scanning:
To use the ClamAV daemon for scanning, first ensure that the daemon is running:
sudo systemctl start clamav-daemon
Next, use the clamdscan
command to perform the scan, for example:
clamdscan /path/to/your/file
or
clamdscan -r /path/to/your/directory
- Schedule regular scans:
To perform regular ClamAV scans, you can use cron
jobs. First, create a shell script, such as clamav_scan.sh
, and add the following content:
#!/bin/sh
clamscan -r --log=/path/to/your/logfile /path/to/your/directory
Add execution permissions to the script:
chmod +x /path/to/your/clamav_scan.sh
Next, edit the cron
jobs using the crontab -e
command and add a line to set up regular scans (for example, to run every day at 1 AM):
0 1 * * * /path/to/your/clamav_scan.sh
文章评论