$linuxjunkies
>

clamscan(1)

Scan files and directories for malware using the ClamAV antivirus engine.

UbuntuDebianFedoraArch

Synopsis

clamscan [OPTION]... [FILE/DIR]...

Description

clamscan is a command-line antivirus scanner that uses the ClamAV virus database to detect malware, trojans, and other threats in files and directories. It scans local files and can be run on-demand or integrated into automated security workflows.

By default, clamscan only reports infected files and returns an exit code indicating the scan result. It does not remove infected files unless explicitly configured, making it safe for initial threat detection.

Common options

FlagWhat it does
-r, --recursiveScan directories recursively, including all subdirectories
-i, --infectedPrint only infected files instead of all files scanned
--removeRemove infected files automatically (use with caution)
--move=DIRMove infected files to specified directory instead of removing
-z, --allmatchContinue scanning a file after finding a match (detect multiple threats)
--max-filesize=SIZESkip files larger than specified size (e.g., 50M, 2G)
--log=FILEWrite scan report to specified log file
-v, --verboseDisplay detailed information during scanning
--database=FILEUse custom virus database file instead of default
--exclude-dir=DIRSkip specified directories during recursive scan
--phishing-sigsEnable detection of phishing signatures and URLs
--bellRing bell on virus detection

Examples

Recursively scan all files in documents directory and subdirectories

clamscan -r /home/user/documents

Scan ZIP files in downloads folder, showing only infected files

clamscan -i /tmp/downloads/*.zip

Recursively scan web directory and move any infected files to quarantine

clamscan -r --move=/quarantine /var/www

Scan home directory recursively and save detailed report to log file

clamscan -r --log=/var/log/clamav-scan.log /home

Scan with verbose output, skipping files larger than 100MB

clamscan --max-filesize=100M -v /data

Scan entire filesystem recursively, excluding system pseudo-filesystems

clamscan -r --exclude-dir=/proc --exclude-dir=/sys /

Scan a single email file for embedded threats

clamscan email.eml

Scan temp directory detecting multiple threats per file, showing only infected

clamscan -r --allmatch -i /tmp