Launcher Products Bitnami Documentationimaxe CLI Blog Contact
imaxe clamav antivirus v1.0.0

Antivirus, always up to date

Scan files and directories for malware with the ClamAV engine, isolate what's infected in quarantine and keep the signatures current with freshclam. One command scans; another updates — no surprises.

$ imaxe clamav scan /srv/uploads --recursive --quarantine
Version
v1.0.0
Subcommands
5
Config
/etc/imaxe/clamav.yml
Requires root
yes
Signatures
freshclam

What this module does #

An antivirus compares the files on your server against a catalog of signatures of known malware. If something matches, it flags it as infected so it can't keep circulating — for example, a malicious attachment uploaded to a public folder or a tainted file that arrived over FTP.

The clamav module puts the ClamAV engine within reach through a handful of clear commands: check its status, scan whatever path you want (a file or an entire tree), decide what to do with anything infected — just report it, delete it or move it to a safe quarantine from which you can restore it later — and keep the signature database current with freshclam. Quarantine isolates the file without deleting it, so you never lose anything by mistake.

Before you start

A scan detects with whatever signature database you have at that moment. If you haven't updated in days, run imaxe clamav update first so you don't miss recent threats. Scanning large trees can take time and use CPU: narrow the path down to what you really want to check.

Quick startstep-by-step tasks

Common tasks #

Pick what you want to do. Each recipe comes with the command ready to go — just swap the path for yours and hit Copy.

1

See whether ClamAV is ready

Checks the engine, the mode and how old your signatures are.

Connect to your server over SSH and ask for the overall status:

terminal
$ sudo imaxe clamav status

Interested only in the signature database — version, date and files? Use db:

terminal
$ sudo imaxe clamav db
You'll see the engine, the mode (daemon or on-demand), the freshclam status and how old the signatures are. If they're stale, jump to Update the signatures.
2

Scan a folder

Check a path and keep the report, without touching anything.

Scan a directory and all its contents with --recursive. By default it only reports: it deletes and moves nothing.

terminal
$ sudo imaxe clamav scan /home --recursive

Just a single file? Pass it the direct path, without --recursive:

terminal
$ sudo imaxe clamav scan /srv/uploads/factura.pdf
When it finishes you'll see how many files were checked and which ones, if any, match a signature. If something infected turns up, move on to the next recipe.
3

Scan and isolate what's infected

Automatically moves everything that tests positive to quarantine.

Scan a path and, with --quarantine, move each infected file into quarantine instead of leaving it where it is:

terminal
$ sudo imaxe clamav scan /srv/uploads --recursive --quarantine

If you'd rather delete what's infected outright instead of isolating it, use --remove (it's irreversible, use it wisely):

terminal
$ sudo imaxe clamav scan /srv/uploads --recursive --remove
The positive files leave their folder and are kept stored and isolated. No one can run them, and you decide later whether to restore or delete them.
4

Review and restore the quarantine

See what's isolated and recover a false positive if you need to.

List what's in quarantine — each entry comes with its identifier, source, signature and date:

terminal
$ sudo imaxe clamav quarantine list

Was it a false positive? Restore it to its original path using the identifier shown in the list:

terminal
$ sudo imaxe clamav quarantine restore a1b2c3d4

Once you confirm that everything isolated is junk, empty the quarantine for good:

terminal
$ sudo imaxe clamav quarantine purge --yes
You control the quarantine end to end: review, recover what was harmless and delete the rest without a trace.
5

Update the signatures

Download the latest definitions to detect new threats.

Run freshclam to fetch the most recent signature database:

terminal
$ sudo imaxe clamav update

Afterwards, confirm the database is up to date with its version and date:

terminal
$ sudo imaxe clamav db
Your scans from now on recognize the latest threats. Update often — new malware appears every day.
Careful with --remove

Deleting removes the file with no way back, and no antivirus is free of false positives. When in doubt, always use --quarantine: it isolates just as well and lets you restore if you got it wrong.

CLI referencecommands, flags and files

Synopsis #

usage
imaxe clamav <subcomando> [<ruta>] [--recursive] [--quarantine|--remove] [--json]

The subcommands that scan, move or delete files require root privileges (use sudo), because they read other users' paths and write to the system quarantine. Add --json to any command for machine-readable output, suitable for scripting.

Subcommands #

SubcommandWhat it doesRelevant flags
statusClamAV status: engine, mode (daemon/on-demand), freshclam and signature database.--json
scanScans a path; can report, delete or quarantine what's infected.--recursive, --remove, --quarantine, --json
updateUpdates the signature database via freshclam.--json
dbSignature database information: version, date and files.--json
quarantineManages the quarantine of infected files (subcommand group).list · restore · purge

The quarantine group gathers three subcommands:

SubcommandWhat it doesRelevant flags
quarantine listLists the files in quarantine (source, signature, date).--json
quarantine restoreRestores a file from quarantine to its original path or a given destination.<id> [<destino>]
quarantine purgePermanently deletes everything in quarantine.--yes

Arguments and flags #

Flag / argumentTypeDefaultDescription
<ruta> req.pathIn scan, file or directory to scan.
<id> req.stringIn quarantine restore, identifier of the quarantined item (shown in quarantine list).
<destino>pathruta originalIn quarantine restore, path to restore the file to. Defaults to its original location.
--recursiveboolfalseIn scan, recursive scan of directories.
--quarantineboolfalseIn scan, moves the infected files to quarantine.
--removeboolfalseIn scan, deletes the infected files. Irreversible; mutually exclusive with --quarantine.
--yesboolfalseIn quarantine purge, confirms the deletion without asking.
--jsonboolfalseEmits the result as JSON on stdout. Available in every subcommand.

Files and paths #

PathContents
/etc/imaxe/clamav.ymlModule configuration: quarantine directory and paths excluded from the scan.
/var/lib/imaxe/clamav/quarantineQuarantine store: this is where infected files that can be restored are isolated.
/var/lib/clamav/Signature database maintained by freshclam (malware definitions).
/var/log/imaxe/clamav.logStructured log of every scan, quarantine and update.

Example clamav.yml:

/etc/imaxe/clamav.yml
quarantine_dir: /var/lib/imaxe/clamav/quarantine
scan:
  exclude:
    - /proc
    - /sys

scan.exclude is a list of paths the scan skips; it comes empty by default.

Exit codes and logs #

Each run returns a code you can check with echo $? — handy for chaining in scripts:

0OKOperation successful; no threats.
1ERRGeneric unclassified error. Check the log.
2USAGEInvalid or missing arguments.
3INFECTEDThe scan found infected files.
4UPDATESignature update failed (freshclam).

Follow the log live while you troubleshoot:

terminal
$ sudo tail -f /var/log/imaxe/clamav.log

Troubleshooting #

SymptomLikely causeFix
You get INFECTED (code 3)The scan detected one or more threats.Review the report; run scan again with --quarantine to isolate them.
You get UPDATE (code 4)freshclam couldn't download the signatures (network or mirror down).Check the server's Internet access and retry clamav update.
The scan takes too longThe path covers too many files or system paths.Narrow the path down and exclude what's unnecessary with scan.exclude in clamav.yml.
I lost a legitimate fileFalse positive moved to quarantine by --quarantine.Locate it with quarantine list and recover it with quarantine restore <id>.
The status shows stale signaturesfreshclam hasn't run in a while.Run clamav update and verify with clamav db.

Stuck with the ClamAV module?

Write to us with the output of «imaxe <module> status --json» and we'll get back to you fast.

Contact support